Homework #10 - Due Wed, Mar 26 2003
Develop an object oriented class that stores 10 apstrings (I would
recommend an apvector of 10 apstrings to store the value). The
class will need to provide accessors and modifiers to the individual
apstrings (accessed via an index) and will need to ensure that a sort
is run after every modifier call (to ensure that the apstrings are
always sorted in alphabetical order). (remember that you can say
apstring1 > apstring2 to find out if apstring1 is higher
alphabetically) You will need to write a find method that
will take in an apstring and will return the index where that apstring
is currently at in the collection. (this find method needs to
implement a binary search) In addition you will need to overload
the == (equals) operator in order to compare the 10 elements of the
internal vector in each class and return true if both instances store
the same values. (meaning every single one of them match)
In summary, your class will need the following:
a .h file with the class definition
a .cpp file with the following methods defined
void sort() // this should be private
apstring getstring(int index)
void setstring(int index) // make sure you run the sort function at the
end of this function
int find(const apstring &findit) // return -1 if you cannot find
the apstring, and this is probably best done as a recursive binary
search function that is called from within find especially since you
are required to make this a binary search function
and an overloaded == operator that returns a bool.