Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

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.

Using Java to 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

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

Advances In Database Technology Edbt 88 International Conference On Extending Database Technology Venice Italy March 14 18 1988 Proceedings Lncs 303

Authors: Joachim W. Schmidt ,Stefano Ceri ,Michele Missikoff

1988th Edition

3540190740, 978-3540190745

More Books

Students also viewed these Databases questions

Question

How flying airoplane?

Answered: 1 week ago