Answered step by step
Verified Expert Solution
Question
1 Approved Answer
how to write the code for shopping cart and store view here is the information for m1 MILESTONE 2 Overview In this milestone, you will
how to write the code for shopping cart and store view
here is the information for m1
MILESTONE 2 Overview In this milestone, you will be defining and coding the beginnings of the StoreView and Shopping Cart classes. You will likely have to refactor some of your code from Milestone 1 and make additions to the Store Manager class. Keep in mind that most of the tasks you will be required to do are relatively open-ended. You must justify any decisions you made that were not obvious in your Change Log. Refer to the examples in Milestone 1. The Shopping Cart Class The ShoppingCart class is very similar to the Inventory class in purpose. A Shopping Cart will keep track of the state of the user's shopping cart. It should maintain the contents that the user adds to it. Remember, the user can also remove items. Shopping Carts are maintained for every user by the Store Manager class as previously mentioned. The StoreView Class The StoreView class will manage the GUI for your system. For this milestone, it will be textually displayed in the console. Note that the Store View class must contain the main() method (i.e. the entry point of the program). Each instance of the StoreView class contains a Store Manager and a unique cartID used to identify the user of the system. In our case, each Store View instance will have a unique cartID. You can choose how the StoreView class will obtain the Store Manager and cartID (you can pass them via a constructor if you want). However, the cartiD should be generated by the StoreManager class. An example of how the StoreView textual User Interface (UI) can look is shown in the figure below. The Product Class The Product class will store information about items being sold by the store. A Product object must only have a (1) name, (2) id, and (3) price. It does not have any other fields. The information in these fields should be retrievable but cannot be changed once the Product object is created. The Inventory Class The Inventory class will track the state of the inventory of your system. It should keep track of the type and quantity of each Product, as well as provide methods to access and modify this information. The following functionalities should be available in any given Inventory object: Get the amount of stock for a given Product ID (Note: it is possible the Product does not exist in the Inventory!). Add a specified amount of stock for a given Product to the inventory (Note: new Products can be added!). Remove a specified amount of stock for a given Product ID from the inventory (Note: you cannot have negative stock, and you cannot delete Products from the Inventory; if a Product's stock reaches 0, leave it.). Get information on a Product given a Product ID. Initialize the Inventory; set the contents of the Inventory to some default values upon object creation. The Store Manager Class Store Manager is the brain" of the system. It contains all the functionality for managing the Inventory, Shopping Carts, and providing information to the Store View class. Store Manager manages a single Inventory and it will have a variety of methods two for now- to interact with this Inventory object. A Store Manager object should: Create a new Inventory object upon object creation (i.e., when a Store Manager object is created). - Have functionality to check how much stock of a given Product is in the Inventory. Have functionality to process a transaction given an Array of Product information. For example, imagine that the content of a user's shopping cart is as follows: "[[productID1, quantity), [productID2, quantity], [productID3, quantity]!. Given each productID, your method should: o Check that the desired quantity exists in the Inventory and return the total for all of the Products o If there is insufficient quantity of any of the products, your method should return some indication of this failure. It could be, for example-1. o Remember to subtract the quantities from the Inventory stock if the transaction is successful. MILESTONE 2 Overview In this milestone, you will be defining and coding the beginnings of the StoreView and Shopping Cart classes. You will likely have to refactor some of your code from Milestone 1 and make additions to the Store Manager class. Keep in mind that most of the tasks you will be required to do are relatively open-ended. You must justify any decisions you made that were not obvious in your Change Log. Refer to the examples in Milestone 1. The Shopping Cart Class The ShoppingCart class is very similar to the Inventory class in purpose. A Shopping Cart will keep track of the state of the user's shopping cart. It should maintain the contents that the user adds to it. Remember, the user can also remove items. Shopping Carts are maintained for every user by the Store Manager class as previously mentioned. The StoreView Class The StoreView class will manage the GUI for your system. For this milestone, it will be textually displayed in the console. Note that the Store View class must contain the main() method (i.e. the entry point of the program). Each instance of the StoreView class contains a Store Manager and a unique cartID used to identify the user of the system. In our case, each Store View instance will have a unique cartID. You can choose how the StoreView class will obtain the Store Manager and cartID (you can pass them via a constructor if you want). However, the cartiD should be generated by the StoreManager class. An example of how the StoreView textual User Interface (UI) can look is shown in the figure below. The Product Class The Product class will store information about items being sold by the store. A Product object must only have a (1) name, (2) id, and (3) price. It does not have any other fields. The information in these fields should be retrievable but cannot be changed once the Product object is created. The Inventory Class The Inventory class will track the state of the inventory of your system. It should keep track of the type and quantity of each Product, as well as provide methods to access and modify this information. The following functionalities should be available in any given Inventory object: Get the amount of stock for a given Product ID (Note: it is possible the Product does not exist in the Inventory!). Add a specified amount of stock for a given Product to the inventory (Note: new Products can be added!). Remove a specified amount of stock for a given Product ID from the inventory (Note: you cannot have negative stock, and you cannot delete Products from the Inventory; if a Product's stock reaches 0, leave it.). Get information on a Product given a Product ID. Initialize the Inventory; set the contents of the Inventory to some default values upon object creation. The Store Manager Class Store Manager is the brain" of the system. It contains all the functionality for managing the Inventory, Shopping Carts, and providing information to the Store View class. Store Manager manages a single Inventory and it will have a variety of methods two for now- to interact with this Inventory object. A Store Manager object should: Create a new Inventory object upon object creation (i.e., when a Store Manager object is created). - Have functionality to check how much stock of a given Product is in the Inventory. Have functionality to process a transaction given an Array of Product information. For example, imagine that the content of a user's shopping cart is as follows: "[[productID1, quantity), [productID2, quantity], [productID3, quantity]!. Given each productID, your method should: o Check that the desired quantity exists in the Inventory and return the total for all of the Products o If there is insufficient quantity of any of the products, your method should return some indication of this failure. It could be, for example-1. o Remember to subtract the quantities from the Inventory stock if the transaction is successfulStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started