Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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. 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
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