Question: Add a class called Inventory . java to your CakeShop project. The class has an ArrayList of Cakes and a method addCake to add a

 Add a class called Inventory . java to your CakeShop project.

Add a class called Inventory . java to your CakeShop project. The class has an ArrayList of Cakes and a method addCake to add a new cake to the inventory's ArrayList. The class also has a method listinventory which prints the cards of each individual cake in the inventory, sorted based on the flavor; if the flavor is the same, then it sorts based on price. Update your Cake. java class to add a parametrized constructor to initialize flavor, price, and tiers. Your cake class should implement the Comparable interface. Make sure that your code complies with the principle of least privilege (use best practice for the access levels of your instance variables). Copy and paste the following code to your main method: Inventory cakelnventory = new Inventory(); cakelnventory.addCake(new Cake("Chocolate", 1, 149.99)); cakelnventory.addCake(new Cake("Chocolate", 3, 299.99)); cakelnventory.addCake(new Cake("Carrot", 2, 99.99)); cakelnventory.addCake(new Cake("Vanilla", 6, 199.99)); cakelnventory.listInventory(); After executing the program, the output should look like this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!