Objective: In this assignment, you will create 4 classes that could be used to maintain the storage of media items in a library or that an individual owns. These classes will represent generic media eitems, CDs, DVDs, and books on tape. You will also write a driver program that uses these classes and illustrates polymorphism. You will use the Eclipse IDE and its features to ease the implementation of the classes.
Due: Before Wednesday's class.
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. (Use the super mutator methods when
appropriate.) 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 child classes, as appropriate.
Start Eclipse on the command line by
typing eclipse.
If necessary, click the arrow button that says "Go to Workbench"
Select File --> New --> Project and
then Java to create a new Java project.
Name the project Assign5. (I believe all the default
values are correct and you can click OK to all the dialog boxes.)
The Assign5 project is stored in a directory in your
Eclipse workspace directory, which is
located in your home directory.
With the Assign5 project selected, create a new class
from the File menu. Name it the
MediaItem class. (For now, ignore the warning about the
default package.) Make the class abstract. You can have
Eclipse create a default main method and generate
comments for you if you select those checkboxes (which I
recommend).
All media items have the following characteristics:
Create appropriate instance variables for this data.
All media items have the following behaviors:
toString method (of course! it is an Object!)Don't just write these methods. Use Eclipse to do
the heavylifting for you. Right click on your program, and
select Source
--> Generate Getters and Setters
or Override/Implement Methods and select the
appropriate methods. (See how much easier that is?)
You can also automatically generate constructors from
the Source menu.
CDs, DVDs, and books on tape have all of the characteristics and behaviors of media items.
Make sure you test each class along the way. You can put
your test code in the
main method of the class. It's easier to catch errors if
you test small parts.
You can execute the test code in the main method using
several different methods:
main method OR
Follow one of the above procedures for executing the code you write in the rest of the assignment.
Create a CD class. In the "New Class" window, make
sure you put in the name of the parent class (MediaItem).
CDs have the following additional characteristics and behaviors:
Create classes for DVD and
BookOnTape
DVDs have the following additional characteristics and behaviors:
String for the rating.
(What would be another appropriate way to represent these
ratings?)
MediaItem's method for getting the
playing time.)Books on tape have the following additional characteristics and behaviors:
To test your classes, you will write a driver program that uses them. (Of course, you were testing 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 a library. Your driver program will
Save the output in a file. The alternatives:
bin
directory of your Assign5 project directory and run java
Driver > ../outputfile I put the output file in the
parent directory so that you can see it in Eclipse. If you don't
see it in Eclipse, refresh the navigator display.Using Eclipse, generate Javadocs for all of your classes, including your driver program. You may find it useful to refer to these while you're developing too.
To generate the Javadoc, use File -->
Export and under Java, select Javadocs.
From your home directory, go into
your public_html directory and create
a cs209 directory. Inside
the cs209 directory, create
a assign5 directory.
Open a web browser and point
to http://www.cs.wlu.edu/~yourusername
You should
see your cs209 directory, if you don't
already have a home page. Click on the link. You should see
your assign5 directory. If you already have
a homepage, you can make a link to your cs209 directory from the web
page, or you can navigate directly
to http://www.cs.wlu.edu/~yourusername/cs209
Copy the Javadocs you generated into
your ~/public_html/cs209/assign5 directory.
OR, export the Javadocs again and make the destination be this
directory.
Load the HTML documentation for your classes up in a browser, by
clicking on the assign5 link.
Copy the workspace/Assign5 project into
your turnin directory, under a directory
named assign5. To be clear, when you copy
your project directory into your turnin directory, the location of
your project directory will
be /home/courses/cs209/turnin/username/assign5/Assign5
You will be evaluated based on the following criteria:
main methods
and the driver program