Your task is to design and code this "shopping cart" prototype. Note that (for now) this prototype does not check the validity of input values. For example, it does not check for invalid pid's, invalid cart id's, etc.
Needless to say?? this version should be coded in the distributed "style" discussed in class.
Catalog
: The Catalog for the OnlineStore contains a Map of the available Products.
Here the key is the 3-digit product id.
OnlineStore
: This class is intended to accept commands from some user interface
- a web or some other GUI. It will be able to create and remove Carts from its
Map
It should also have methods to
Shopping Cart
: A ShoppingCart contains a Map of pid - CartItem pairs.
(There cannot be 2 CartItem's with the same pid. If addToCart does add an pid,
then new quantity is added to the existing quantity.)
CartItem
: A CartItem "knows" the Product
and the quantity that the shopper wishes to purchase.
Product
: (For the purposes of this lab exercise) a Product knows
its description and its regular price.
Add Inventory tracking. For brevity / simplicity assume that your store never runs out of inventory. Assume an initial inventory of 100 items for each Product.
Inventory will update as Products are added and removed from ShoppingCarts. For example, when 5 of pid 111 are added to cartId 2, the inStock value for pid 111 is decreased by 5 and the reserved value is increased by 5. etc. etc.
In addition, your OnlineStore should be able to dumpInventory() to display the current state of its Inventory.
I found sequence diagrams very useful here!
Note that running your code with the Test1 main in the lab5 directory should produce output very much like that in out1.txt.
This assignment is due at the beginning of the Tuesday lab class after the reading break (March 6) at 3:30 p.m. - and the submit program will enforce this