Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Coffee Makers Please implement a small class hierarchy of coffee makers. There is a superclass CoffeeMaker which has two subclasses, Aeropress and KeurigMachine. Each CoffeeMaker

Coffee Makers

Please implement a small class hierarchy of coffee makers. There is a superclass CoffeeMaker which has two subclasses, Aeropress and KeurigMachine. Each CoffeeMaker has a method makeCoffee() which behaves differently depending on the kind of coffee maker.

CoffeeTester class

This class is given to you and contains the main method. Do not modify it in your submission.

CoffeeMaker Superclass

Each 'CoffeeMaker' has a 'modelNumber', which is an integer. It has the following methods:

  • A constructor with an integer parameter for the model number.
  • A method getModelNumber() which returns the model number.
  • An abstract method makeCoffee() that does not return anything.

Aeropress Subclass

  • Aeropress is a subclass of CoffeeMaker.
  • The constructor should have an integer parameter for the model number.
  • Please override makeCoffee() to print the following (including a newline): Push - drip - push - drip
  • Please override toString() to return "Aeropress model " followed by the model number. So, for an Aeropress with model number 55 it would return: "Aeropress model 55"

KeurigMachine Subclass

  • KeurigMachine is a subclass of CoffeeMaker.
  • The constructor should have an integer parameter for the model number.
  • Please override makeCoffee() to print the following (including a newline): Drip drip drip - done
  • Please override toString() to return "Keurig model " followed by the model number. So, for a KeurigMachine with model number 42 it would return: "Keurig model 42"

Please implement this hierarchy according to the specifications above and using best object-oriented programming principles . Any missing details should be filled in using best object-oriented programming principles.

GIVEN CODE

public class CoffeeTester{

public static void main(String[] args){ Aeropress aero = new Aeropress(420); CoffeeMaker keurig = new KeurigMachine(1);

System.out.println(aero); aero.makeCoffee();

System.out.println(keurig); keurig.makeCoffee(); } }

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 Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions