Question
Java coding three classes needed 1- shppingCart class The ShoppingCart class is very similar to the Inventory class in purpose. A ShoppingCart will keep track
Java coding
three classes needed
1- shppingCart class
The ShoppingCart class is very similar to the Inventory class in purpose. A ShoppingCart will keep track of the state of the users shopping cart. It should maintain the contents that the user adds to it. Remember, the user can also remove items. ShoppingCarts are maintained for every user by the StoreManager class as previously mentioned. 2- 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 StoreView class must contain the main() method (i.e. the entry point of the program). Each instance of the StoreView class contains a StoreManager and a unique cartID used to identify the user of the system. In our case, each StoreView instance will have a unique cartID. You can choose how the StoreView class will obtain the StoreManager and cartID (you can pass them via a constructor if you want). However, the cartID should be generated by the StoreManager class You should think of each instance of the StoreView class as a separate user browsing the store. Like multiple users on the internet browsing an online store. However, your store is obviously much simpler.
3- The storeManager Class The StoreManager needs some new functionality. Now, it will not only be managing the Inventory, but it will also be managing user ShoppingCarts. Each user that connects to the store (new StoreView instance) should have their own unique ShoppingCart. If a user adds something to their cart, the Products stock in the store Inventory should be decreased accordingly. A user can also remove items from their cart. Note that if the user removes a product from the shopping cart, the inventory must also be updated accordingly. Upon request, the StoreManager should return a new, unique cartID. This means StoreManager should be keeping track of cartIDs in some way. It could be as simple as having a counter that increments every time a new ShoppingCart is made. A user needs to be able to checkout once they are ready This method should return the total and summary of the items in the cart (print it for the user to see). You can choose to disconnect the user at this point or reset the cart up to you! If the user quits before checking out, any items in the cart should be returned to the Inventory stock. Note: quitting means the user entered quit, not your program suddenly closes; you do not need to worry about that. Now that you will be implementing the UI for the store, you need some way to get the information needed to drive this UI. StoreManager should have some methods that return needed information about ShoppingCarts, or available Products. The StoreView class will be using this information to populate the UI for the user. Remember, all communication by the StoreView class must be done with the StoreManager only! Questions 1. What kind of relationship is the StoreView and StoreManager relationship? Explain. 2. Due to their behavioral similarity, would it make sense to have ShoppingCart extend Inventory, or the other way around? Why or why not? 3. What are some reasons you can think of for why composition might be preferable over inheritance? These do not have to be Java-specific. 4. What are some reasons you can think of for why inheritance might be preferable over composition? These do not have to be Java-specific.
Step 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