In this assignment, you will create 4 classes that could be used to maintain a database of media items in a library or that an individual owns. These classes will represent generic media items, CDs, DVDs, and books on tape. You will also write a driver program that uses these classes and illustrates polymorphism.
All media items have the following characteristics:
All media items have the following behaviors:
CDs, DVDs, and books on tape have all of the characteristics and behaviors of media items.
CDs have the following additional characteristics and behaviors:
DVDs have the following additional characteristics and behaviors:
Books on tape have the following additional characteristics and behaviors:
You are to implement four classes, MediaItem, CD, DVD, and BookOnTape. CD, DVD, and BookOnTape must all extend MediaItem. You must provide at least one constructor for each class that takes parameters to set all instance variables. You should make all the instance variables private in all classes. You are not to repeat instance variables from MediaItem in the classes that extend it. You will have to override some of the methods in MediaItem in the various sub classes, as appropriate.
The driver program emulates a library that keeps track of all the media that is in the library. Your driver program will
When you execute your program, demonstrate your program's ability to handle strange or incorrect behavior as well.
sprenkle.assign2
.
(Remember what this means for the directory structure of your
classes.) You can have additional packages underneath this prefix.
For example, the full package for my assignment could be
sprenkle.assign2.library.media
You will submit your final HTML Java Docs too, on paper and electronically. Do NOT print out the raw HTML code (e.g.,
<html> <body> ...Load the HTML documentation for your classes up in a browser and print from there. Print the package summary page as well as the documentation for each individual class.
If you use Eclipse to run your program, you can copy the text in
the Console window from your program's execution and pastes it into
Notepad, or some other form that you can save and print. Or, you can
upload (ftp) your code to strauss and use the script
command there. Eclipse is just a development environment. Java is
portable, so you should be able to run your code on any machine that
has a JVM.
Submit a printed version of your assignment (script file, Java files, Java Docs, and README) at the beginning of class on Thursday, June 22.
Electronic Submission Organization
Your submission directory will look something like this:
Email a gzipped tar file of your assignment directory (named
lastname
, as shown above), which includes the
script file, the Java files, the class files, the docs, and README to
Ke (kli at cis.udel.edu) before next Thursday (June 22) at 11:59:59
p.m. The name of your zipped submission should be
lastname-assign2.tar.gz
(or .zip or whatever the
appropriate extension). The subject line should be "[Your Name]
CISC370: Assignment 2 Submission".
If necessary, see Assignment 0 for instructions for generating the tar file.
If you have any questions about submission, ask early!
We will follow similar directory structures in future submissions.
This problem is based on a similar example from Objects First With Java by David Barnes and Michael Kolling.