Question
Java help, please! Please tell me what I did wrong. In this assignment you will be creating an application for an ice cream shop. Create
Java help, please! Please tell me what I did wrong.
In this assignment you will be creating an application for an ice cream shop. Create an interface named Flavor. Create three subclasses Lemon, Mint, and Chocolate. Create a class named Cone that has a single member variable named scoops of type List with a generic argument of Flavor. Initialize the scoops member variable to an object of one of the two list classes discussed during the lecture. Add a method named add with a single parameter of type Flavor named scoop. This will add the scoop object to the scoops list.
Create a class named IceCreamShop. The class has a single member variable of type Map named orders. Initialize this map to an instance of type HashMap. This map is used to track customer orders. It maps a customer name of type String to an instance of Cone. The map is modified by the following methods:
- Add a method orderScoop(String customer, Flavor flavor). This method first checks if theres already an order for the given customer in the map. If the map does not have an entry with the customer name, a new entry is put into the map with a new Cone object. If the map already contains an entry, it gets the cone value from the map. Then it adds a new flavor to the cone. Note: Theres no need to put the cone back into the map because the map uses a reference to the cone object.
- Add a method completeOrder(String customer). This method will return the cone for the given customer and remove the entry from the map.
interface \} class Lemon \} class Mint class Chocolate \} class Cone \{ private List> orders = public void orderScoop(String customer, Flavor scoop) \{ if ('this.orders. (customer)) \{ this.orders. (customer, ); \} Cone cone = orders. (customer); cone. (scoop); \} public Cone completeOrder(String customer) \{ Cone cone = orders. (customer); orders. (customer); return ; \} \}
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