Assignment 5: Eclipse and Inheritance Practice

Objective: 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. You will use the Eclipse IDE and its features to ease the implementation of the classes.

Due: Before the next class on Wednesday, Sep 24.

BUT, you will also have another little assignment due on Wednesday that I will give you on Monday.

Overview

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 sub classes, as appropriate.

Using Eclipse

You can start Eclipse one of two ways: through the Applications Menu, under Programming or, on the command line, type eclipse.

Click the arrow button that says "Go to Workbench"

Set Up

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.

Creating a class

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.) You can have Eclipse create a default main method for you if you select that checkbox.

All media items have the following characteristics:

Create appropriate instance variables for this data.

All media items have the following behaviors:

Don't just create these methods. Use Eclipse to do some of the work 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 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. It's easier to catch errors if you test small parts.

Creating Child Classes

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:

DVDs have the following additional characteristics and behaviors:

Books on tape have the following additional characteristics and behaviors:

A driver program

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

Javadocs

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.

Putting them on the Web

From your home directory, go into your public_html directory and create a cs209 directory. Inside that directory, create assign5 directory.

Open a web browser and point to http://www.cs.wlu.edu/~yourusername
You should see your cs209 directory. Click on the link. You should see your assign5 directory.

Copy the Javadocs you generated into your public_html/cs209/assign5 directory.

Load the HTML documentation for your classes up in a browser, by clicking on the assign5 link.

Turnin

Copy the workspace/Assign5 project into your turnin directory.

Grading (100 pts)

You will be evaluated based on the following criteria: