©2005 Felleisen, Proulx, et. al.
You will start this assignment with the given code. The code defines a list of objects, a class that represents a person, and its derived class that represents a student. There are no examples of data. Some methods are already defined, but do not include tests. By filling in the missing pieces of the design recipe, you will become familiar with the code. You will then add new methods to this class hierarchy.
Draw a class diagram for the given class hierarchy.
Make examples of data as required by the design recipe.
Design and run tests for all methods in the class hierarchy that represents a list of objects, using a list of students as the sample data.
Design the method filter that produces a list of all
objects that satisfy the given predicate.
Design an interface ICompare that contains a method
betterThan which takes as argument one Object and
returns a boolean value.
In the class Person the basis for the
betterThan comparison is the alphabetical ordering of the
names. In the class Student the ordering is
determined by the gpa. Modify each class to implement the
ICompare interface accordingly.
Add to the classes that represent a list of Objects
the method(s) that implement insertion sort, the ordering
determined by
the betterThan method of the ICompare
interface. Test is with both, lists of Persons and lists of
Students.
Design the method that verifies that a list is sorted according
to the ordering determined by the betterThan method of the
ICompare interface.
Design and implement quicksort for the list of
Objects. (Refer to HtDP for the explanation of quicksort.)
Define an interface IObj2Obj which contains a method
that consumes one Object and produces another
Object.
Define a class that implements this interface by consuming an
instance of the class Student and producing a
String that
contains student's id, name, credits, and gpa. For example, it may
produce
"1234, Jenny Smart, 34 credits, gpa 3.4".
Write a test case that produces a list of Strings
representing all honors students (with gpa greater than
3.5).
Write a test case that produces a list of Strings that
represent all students with more than 80 credits.