Exercise 8.1 Study the given IRange interface for an iterator and its use with the list of Student. An example shows how to use the iterator to find whether a student with the given name is in the list and how to print all items in the list.
Draw the UML diagram of this collection of classes.
Develop another example of the use of this iterator to determine whether a student with gpa greater than 3.5 is in the list.
Use a similar technique to design a method in the test suite, which computes the best gpa of all Students in this list.
Use a similar technique to design a method in the test suite, which counts the number of students in this list.
Use a similar technique to design a method in the test suite, which computes the average gpa of all students in this list.
Exercise 8.2 The given code defines also an ArrayRange iterator and a TreeRange iterator for binary trees. Use the ArrayRange iterator and the TreeRange iterator to perform the same tasks as in the previous example.
Exercise 8.3 The given code defines a binary search tree of Integers (BST), and an iterator which implements IRange to traverse the tree in inorder.
Develop a test suite that tests the iterator on a BST with at least 7 nodes.
Design and test a ReverseTreeRange iterator which traverses the BST in reverse inorder.
Exercise 8.4 Design the class DataSet which has as its member data a data collection of Comparable objects, such as list of Integers, or an array of Strings, and a corresponding iterator. Design the following methods in this class:
findItem method, which determines whether a given object appears in the data collection
count method, which counts the number of items in the collection
minimum method, which returns the minimum item in the collection. The method may assume that it will only be invoked by with a non-empty collection.
Make sure you develop the tests for these methods that use at least two different data collection and their corresponding iterators.
Exercise 8.5 (Will be avilable later.) Use the given IRange interface and its FileRange implementation to perform the following tasks:
Develop the classes to represent a Binary Search Tree (BST)of arbitrary Comparable objects.
Develop the method which reads the data from a file using the FileRange iterator and builds a BST. Test your result using the code from previous exercises.