Exercise 1.1 The given code contains the following class definitions:
ALibRec an abstract class of library record
Book a class representing one book
CD a class representing one CD
Person a class representing one person (book author or CD artist)
ALoLR a list of library records
EmptyLoLR empty list of library records
ConsLoLR constructed list of library records
TestSuite collection of sample objects and some tests
The purpose of this exercise is to learn techniques for testing of different forms of equality.
Draw the UML diagram for this class hierarchy
Implement Comparable interface for the classes Book and CD, comparing the items by the last name of either the author or the title. You must be able to compare a CD with a Book , etc.
Design the methods sort and insert which together will sort the list of library records. The test suite is provided - just remove the comments.
Object equality
Design the method eq which determines whether two library record variables represent the same instance of a library record object. Use a similar definition in the class Person as a model.
Design the method equalContents which determines whether two library objects contain the same information. Use a similar definition in the class Person as a model.
Equality of collections of data.
Design the method equalObjects which determines whether the variables representing two lists of library records represent a collection of the same instances of library record objects.
Design the method equalSortedObjects which determines whether the variables representing two lists of library records represent a collection of the same instances of library record objects, appearing in the same order.
Design the method equalContents which determines whether the two lists of library records contain records with the same contents.
Design the method equalSortedContents which determines whether the two lists of library records contain records with the same contents, appearing in the same order.
In the TestSuite define a function EqualArrayObjects which consumes two arrays of library records and determines whether they contain the same objects. You may assume that both arrays are sorted.
In the TestSuite define a function EqualArrayContents which consumes two arrays of library records and determines whether they contain the same number of elements with the same contents. You may assume that both arrays are sorted.