CSE2305 - Object-Oriented Software
Engineering
assessment
The List::Node
class is used to store individual elements in
the list, linked by pointers. It is private to the List class since it is part
of the internal working of the List class (encapsulation).
List
allocates memory each time List::Insert
is
called. When an object is destroyed it should free any memory allocated by
the object using the new
operator.
List.h |
|
List.C |
|
List.h |
|
List.C |
|
main.C |
cout << "Now, please enter a search term: " << endl; cin >> word; cout << "Search term '" << word << "' was "; if (!myList.Search(word)) cout << "not "; cout << "found in the lists." << endl; |
Sorting should be done in lexicographic
order. In the example below, this is implemented using the standard library
lexicographical_compare
function. However, you could easily do
your own version that compares two strings in a case insensitive manner, one
char
at a time. Notice the use of the static function nocaseCompare()
which uses the function toupper
, also included as part of the
C++ standard library. (You were given a hint about this in the assignment specification.)
List.h |
|
List.C |
|
UML notation for the List
class. Note the compositional relationship between List
and Node
. Depending on which flavour of UML you use (how old your text book and the specification), these depictions of Node as an inner class of List may (or may not) be correct. You will not lose marks for using a minor variation of what apppears below as long as the relationships are shown clearly.
(a)
(b)
(c)
Last Modified: August 18, 2006