CS 280 Spring 2008

Assignment 12 – Inheritance – and bringing together a bunch of other things that we’ve done

100 points

 

Assigned: 04/16/2008

Due: 04/25/2008 at the start of class (last day of classes) (we have 2 labs between now and then – but one is the day before this is due – don’t procrastinate!!!!)

 

Pre-Lab (Do Before Lab):  Bring materials – a USB for a take home copy.  Download, unzip and familiarize yourself with the partial classes etc that I’m providing – MusicalGenre, MovieGenre, and MovieRating enumerated types, ID class,  Product class, CD class, DVD class, and GUI driver class. Read the assignment and try to identify and understand your key tasks.

 

Main Assignment:

You are writing some parts of a simplified simulated music and movie purchasing program (well, a little more than a demo). We are still quite a ways away from being able to do the whole job, and I have provided a large amount of code, so please pay attention to what I’m asking for. Your job is to update the provided classes as indicated. Most of the methods you will write are in the Javadoc documentation for the classes.  The code is provided in a single zip file on Blackboard (they are in multiple projects).  The zip also includes the javadoc generated html documentation for the classes.

The relationships among classes – A Product “has-a” ID. A CD “is-a” Product. A DVD “is-a” Product. A CD “has-a” MusicalGenre. A DVD “has-a” MovieGenre and MovieRating. The GUI “has-a” ArrayList of CDs, an ArrayList of DVDs, plus a current CD and current DVD.

Status of things:

·         The ID class is complete.

·         The MusicalGenre enumerated type is sufficient

·         The MovieGenre enumerated type is sufficient

·         The MovieRating enumerated type is sufficient

·         The Product class needs the following

o    Pseudo-inspector getRevenues which gives the total money brought in by sales of a Product. This method should be used in at least toString and compareTo..

·         The CD class needs the following:

o    A Constructor that is passed the following (in order): a skuLen, a name, a price, a cost, a number in inventory,  a number sold so far, an artist name, and a musical genre (enumerated type – not the String corresponding).  A random SKU of the given length should be constructed (easily!! You shouldn’t be writing a lot of lines of code for this).  This method may not be used in the current application, but make sure it works correctly!

o    A toString method

·         The DVD class needs the following:

o    A toString method

o    An equals method that returns whether all of the contents of two DVDs are equal. This method may not be used in the current application, but make sure it works correctly!

·         The GUI class needs the following:

o    Handling of the Sort buttons for both CDs and DVDs (this should be VERY easy)

o    Handling of the Resupply buttons for both CDs and DVDs. CDs are always reordered in a batch 5 at a time and DVDs are always ordered in a batch 3 at a time.  There are constants in these classes that can/should be used.

o    Handling of the Buy buttons for both CDs and DVDs. Invalid quantities should not be able to be purchased (zero or less or more than are in inventory) – the appropriate controlled mutator method should already exist for buying that will return a Boolean indicating if the purchase was successful.

o    Handling of refreshing the display of info about the current CD / DVD. The calls to these methods were left in but all but the headers were removed.

There is processing involving files – my code should completely handle this. Sample files are in the proper folder in the zipped folders. The DVD list has all wrong lengths and all prices and costs are completely made up.

                See my simple sample interface below – it probably doesn’t need any adjustment to the GUI except adding your name on the form.  The paper version of this assignment shows a couple of screen shots from different points running my program. The version on my www site shows 9 screen shots from various points.

Make sure the Java version stays 1.5, NOT 1.6.

 

 

 

Hand in:

 

Miscellaneous:

·         Put  your name in the jlabel on the GUI form  

·         If the user enters letters into any numeric inputs  – no worries – we won’t deal with this until we cover exceptions a little more.

o    MAKE SURE YOUR PROGRAM WORKS! (i.e. gets correct results, controls what is displayed/enabled).  It must provide all of the requested capabilities AND provide them in the expected way – don’t change my code to make your code work!  Check that the desired parameters and return types are provided.

o    You MUST include some comments that explain your program in order to get full credit, including a javadoc compatible comment for each method (any place where I didn’t leave mine in)!!

 


On Start Up:

 

DVD Tab:

 

 

 

 

 

 

 

Select A Different CD:

 

 

Protected From Bad Input:

 

 

 

But can purchase 5:

 

 

 

 

 

 

 

 

 

 

 

 

 

Info immediately updated after purchase:

 

 

Reorder currently always supplies 5 copies of the CD:

 

 

(after a bunch of purchases) Sort sorts by Revenues (displayed by Display All – use of toString makes this kinda ugly):

 

 

Write to File:

 

 

DVD processing is really the same (one example):