Checkpoint 2
In the lab 8 sample code you have four related classes: Book, Documentary, Movie, and ReferenceItem, all implementing the Item interface. There is a lot of duplicated code among these classes. Rewrite them to eliminate most of the duplication by using inheritance. At the very least, you should create an abstract class for the code that is common to all four classes. There may be additional opportunities for code reuse.
- All four classes must have the same public API and the same behavior as the originals
- You may not use any
protected
(or non-private) variables - You can add
protected
methods or constructors as you wish - Do not do any type-checking (e.g. using
getClass()
orinstanceof
). Rely on polymorphism to get the correct behavior