CS 250, Spring 2017, Iyengar
Programming Project #3; Due Midnight: 4/28/2017
Dept. collaboration
policy applies to this assignment. You are welcome to work in pairs or
individually. If you pair up with a partner – then it is your responsibility to
as a pair to complete the assignment – no excuses.
Turn in the names of
members in your pair (by email) by end of 3/26/2017. Only these will be
considered for pair programming. Choose a new partner
for this assignment. All other are individual assignments.
Objective: To develop a GUI based Shopping Cart. (100 pts)
You must use the MVC
model of software design. There must be separate classes for the screen, the
listener, and for data handling (that opens files, and handles the data). A
project “Assignment 3” is on the readOnly folder.
Import this project and complete the Driver, GUI, Controller, and the InventoryManager classes in the MVC package.
Note: This Assignment
has product hierarchy and when an object is read – you may recognize its type
using the instanceof
operator. Review the files in Apps and Products packages.
Output:
GUI Interface for displaying items, the shopping cart displaying items selected, a purchase menu/announcement, updated inventory data.
Input:
Import the project “Assignment 3” (with “copy project to workspace”) from the readonly folder for your class.
The following classes are in the
package Products. Read and understand
the implementation of these classes. Do not modify these classes!!
An abstract class Item – which contains a
item_name,
an item_code,
and a price, and inventory.
An abstract class Food (inherits Item) – which contains an expiration_date.
An abstract class Perishable (inherits Food) – which contains a flag to indicate if it is a frozen food or not (true for frozen, false otherwise).
A concrete class Fruit (inherits Perishable).
An abstract class Clothing (inherits Item) – which contains a type (which could be “footwear”, “dress”, “accessories” or “Jewellery”).
A concrete class Shoes (inherits Clothing) – which contains ShoeSize.
An abstract class Electronics (inherits Item) – which contains a type (which could be “Audio” or “Video”).
A concrete class TVS (inherits Electronics) – which contains ScreenSize and integer inventory.
An abstract class Pharmaceutical (inherits Item) – which contains a type (which could be “OTC” or “Prescription”).
A concrete class Pharmacy (inherits Pharmaceutical) – which contains a flag, (for medical (true) or non-medical (false)).
The package Apps contains two application classes that is used to create object data file, and to read object data from this file. Read and understand how this is done.
The java classes that you update
(for Driver, GUI, Controller and InventoryManager)
must be in the MVC package.
An input file Storage.dat contains object data of the inventory. Use this as the file to obtain current inventory. This file should be updated when a purchase event is completed. Subsequent use of this file must reflect changes in the inventory from previous executions.
GUI Control: The GUI screen should have multiple panes using JPanel.
·
There should be a “List of Items” pane that
displays the items list.
·
Selecting an item should display in a different
pane the item description and its unit price.
o There should be a “purchase” button. Upon clicking this button there should be a prompt for number of items to be purchased (of the item selected earlier)
· There should be another “CART” pane that displays the items purchased together with units purchased and the unit price and cost of that purchase. This pane should also update and display the total cost of all purchase.
· Have a “BUY” button. Clicking this button should output the following message on a separate window (JOptionPane is ok).
o “Thanks for shopping with us. Your total cost is $ xxxxx. Please make arrangements for payment.
· Have a “Complete” button upon which the items purchased is listed again with a message “These will be delivered to you. Thanks Again. Have a Nice Day.”
· Also have an “Exit” button on both the List of Items and CART window. Clicking this button – should terminate the application.
The Storage.dat file should be updated with the objects written back with the inventory updated.
For this Assignment you don’t have to delete purchases made.
Assumptions: There will be an initial Storage.dat file containing a sequence of objects.
There will be a max of 25 objects in this file.
There are only 4 concrete classes (Fruit, Shoes, TVS, and Pharmacy)
Upon clicking of the “BUY” button the purchase is assumed and inventory modified – and should be recorded in the file.
Submission:
Questions and Collaboration: Any questions about the problem – email, inquire in class or discuss with instructor or tutor.
You are free to discuss the problem solving part.
Do not view or use code developed by others.
Bonus:
When items inventory go below 10 – an exception
“LowInventoryException”
should be thrown in the
inventoryManager. This should be caught in the controller, and
appropriate message written to a text file - OrderList.txt
Don’t forget to output the correct message to the GUI. (40)
Bonus:
Add images for all products that
is displayed when item is chosen
description. (50)