Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java Polymorphic Problem: Coffee Mocha Implement a program that manages coffees. First, implement a class named Mocha. The Mocha class has three member variables:

In Java Polymorphic

Problem: Coffee Mocha

Implement a program that manages coffees. First, implement a class named Mocha. The Mocha class has three member variables: milkAmount, espressoShot, chocolateType. The Mocha class implements an interface HowToMakeDrink. The interface has the following method:

public interface HowToMakeDrink {

public void prepare ();

}

The prepare function will simply print out the type of drink (CoffeeMocha) and all ingredients of the drink to the screen.

Implement three derived classes named WhiteChocolateMocha, DarkChocolateMocha, and PeppermintMocha. Assign the appropriate value for chocolateType for the first two classes. Add a peppermintSyrubAmount member variable to the PeppermintMocha class including a getter and setter function. Add a constructor to each class that sets the values of all properties. Override the prepare () function in each subclass by printing the coffee/class type and ingredients using the defined properties in that class.

Write a program that repeatedly shows the user a menu to create one of the three mocha drinks or to print all the drinks created so far. If the user selects to create a new mocha drink, the program prompts the user to enter the ingredients of the selected drink. If the user selects to print the current coffees, print the drink type and ingredients of each drink to the console. Creating objects for testing all classes and all functions in the main function.

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions