COMP 15
Programming Assignment 5:
Discounting comes to the Java Stores
Assigned:
Monday Nov 15, 1999
Due:
Monday Nov 22, 1999
You are encouraged to collaborate with classmates on this project.


Problem Description

In this assignment you are asked to make a small set of changes to the Java Store program that was distributed in lecture. The files for this program are available through the class page. The change required is to add an additional parameter to the createBill method to indicate whether a store discount card (we'll call this an MVP card) is presented at checkout.

If the MVP card is presented, then selected item discounts should apply, as recorded in the store database. The discount is expressed as an amount (e.g. 5 cents), not a percentage. You may choose the discounts to record in the database. Keep in mind that the discounts should be recorded separately from the price (since we still need to charge the full price for a customer without an MVP card).

In formatting a bill with an MVP card, each item to which a discount applies (i.e. has a discount value > 0) should be formatted to show the amount of the discount and the price after the discount is applied. In addition, if an MVP card is used, a final line should be added to the bill showing the total MVP savings realized. A sample bill illustrating the output format is shown below.

If no MVP card is presented, the bill should not mention the size of the discount, and display full prices. It also should also omit the total savings line at the end of the bill.

Without MVP cardWith MVP card
              Java Stores               

Scones ..........................  £2.05
Crisps ..........................  £0.37
Marmite .........................  £1.89
(Item not found) ................  £0.00
Crisps ..........................  £0.37
Tea .............................  £1.10

TOTAL ...........................  £5.78

   Thanks for shopping at Java stores   
              Java Stores               

Scones (MVP discount £0.35) .....  £1.70
Crisps ..........................  £0.37
Marmite (MVP discount £0.05) ....  £1.84
(Item not found) ................  £0.00
Crisps ..........................  £0.37
Tea (MVP discount £0.15) ........  £0.95

TOTAL ...........................  £5.23
Total MVP savings ...............  £0.55

   Thanks for shopping at Java stores 


Submission Procedure

For this program, a paper-only submission will be used. You will not have to run your program for us (but please keep a copy of the files for yourself). You may work together, but no more than three names can appear on a joint submission.

You should turn in:

  1. A listing of the Java classes in the distributed program that were changed, with the changes marked with highlighter.
  2. A listing of the output of an execution with an MVP card and without an MVP card.
You can use the "print" function in VJ++ to print the class files and the output window (be sure to stop your program before it completes so that the output window is still available).


$ Revised: Mon Nov 15 1999 by prins@cs.unc.edu