Assignment 2 (100 Pts)

Due: Thursday, June 22

Using Inheritance

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.

A driver program

To test your classes, you will write a driver program that uses these. (Of course, you will test each of your classes along the way too, right?)

The driver program emulates a library that keeps track of all the media that is in the library. Your driver program will

Your driver program may need to provide some utilities to handle initializing the objects.

When you execute your program, demonstrate your program's ability to handle strange or incorrect behavior as well.

Packages

The prefix to your Java class's package for all assignments will be your last name followed by the assignment name. For example, my package name's prefix would be 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

Java Docs

Generate Java Docs for all of your classes, including your driver program. You may find it useful to refer to these while you're developing too.

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.

README

Your README file should contain

Script file

Create a script file showing your README, your code, compilation, and execution of your program.

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.

Submission

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.

Grading (100 pts)


This problem is based on a similar example from Objects First With Java by David Barnes and Michael Kolling.