Book that records the title, author, and price of a book (an int).
Define an interface and implementing classes (using generics) that represent a list. Also, define an interface
called ISelect (as we did in Lecture 19), and two classes: one that implements the ISelect interface so that it
selects a Book by a given author, and the other that implements ISelect so that it selects a Book
cheaper than the given price (hint: the classes that implement ISelect can have fields). Make sure you test the classes that implement the ISelect interface.
filter for your list classes, filtering according to the given
ISelect. Write tests for lists of Books.
// to represent a method that determines whether or not t1 is before t2 in an ordering
interface Ordering<T>{
public boolean isBefore(T t1, T t2);
}
Define at least two classes that implement this interface for Books (you may order the books by price, the length of the
book title, the authors' names, etc.) Test.
sort for the list classes that uses an instance of a class that implements
Ordering to determine the appropriate ordering of the items in the list. Test on lists of Books.
isSorted for the list classes, that uses an instance of a class that
implements Ordering to determine if the list is sorted correctly. Test.
merge for the list classes. merge merges this sorted list with
that sorted list, producing a list that that contains the elements of both lists, again in sorted order.
An instance of the class that implements Ordering determines the ordering of both the original
two lists and the resulting list. Keep testing.
+------------------------+
| abstract class ABST<T> |
+------------------------+<--+
+----------| Ordering<T> order | |
| +------------------------+ |
| / \ |
| --- |
| | |
| ----------------- |
| | | |
| +--------+ +--------------+ |
| | Leaf<T>| | Node<T> | |
| +--------+ +--------------+ |
| | T data | |
| | ABST<T> left |-------+
| | ABST<T> right|-------+
| +--------------+
|
v
+------------------------------------+
| Ordering<T> |
+------------------------------------+
| boolean isBefore(T t1, T t2) |
+------------------------------------+
insert that inserts a new item into this binary search tree, using the
Ordering that is defined for this tree. Test on trees that contain Books.(Clarification: insert returns an
ABST<T>)
getFirst that produces the smallest element in this binary search tree.
In the Leaf class the method should throw a RuntimeException. Test.
getRest that produces a binary search tree that contains all the elements of
this binary search tree except the smallest element. In the Leaf class the method should throw a RuntimeException. Test.
Create an archive of your Eclipse project (see "Saving your work" in Lab 4 if you forgot how to do this). Using web-based turnin, turn in a single zip file containing all code for this assignment (you do not need to turn in the documentation files that Javadoc generates from your Javadoc comments). Follow the naming conventions when naming your file.