The People class holds an unsorted list of humans. Initially, this list is empty

The People class holds an unsorted list of humans. Initially, this list is empty. Upon inserting a Human object, it is added to the array at the next available position and the position value in incremented. If the position value is equal to the size value, do not insert the Human. Instead, throw an exception that your driver can catch to print an error that the People object is full.Create a People class with the following features:Each People object has a statically allocated array of Human objects.
Size attribute representing the maximum size of the array.
Position attribute representing the next free position in the array.
Default constructor with no arguments.
Search method that takes a string argument and returns a Human object. This method returns the first Human object with a name matching the string argument. In other words, pass the name of a Human as a string, search the list of humans for one with that name. If found, return this human. Else throw an exception.
Insert method. This accepts a Human object as an argument. If the list of Humans is not full, insert this into the list then increment position. If the list is full, throw an exception.
You do not need to implement destructor or overloaded operators.You may not use anything from the STL, vectors, or linked lists.This must use an unsorted, fixed size array of your own, original implementation.The search and insert methods must be your own original solution.
Requirements: Full   |   .doc file

Categorized as C#

Leave a comment

Your email address will not be published.