Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What is the importance capital budgeting?

Answered: 1 week ago