Question: In this exercise, we create an abstract Beverage class. We then create two concrete classes, IceWater and Hot Tea. These subclasses differ in their implementation

 In this exercise, we create an abstract Beverage class. We thencreate two concrete classes, IceWater and Hot Tea. These subclasses differ intheir implementation of the drink() method, which is why in the Beverageclass, the drink() method is abstract. Each class contains at least oneerror. There are five total errors across all four classes. Please identify

In this exercise, we create an abstract Beverage class. We then create two concrete classes, IceWater and Hot Tea. These subclasses differ in their implementation of the drink() method, which is why in the Beverage class, the drink() method is abstract. Each class contains at least one error. There are five total errors across all four classes. Please identify all errors and explain what must be done to correct each error. Your response must be in detailed, complete sentences. Important: Each class is contained in a separate file. Below is the source code for all four files: package packagel; public abstract class Beverage { private int ounces; private double price; Beverage (int ounces, double price) { this.ounces = ounces; this.price = price; } public int getOunces () { return ounces; } public double getPrice () { return price; } public abstract String drink(); } package package2; + import package1.*; public class HotTea implements Beverage { public HotTea(int ounces, double price) { super (ounces, price); } public String drink() { return "This tea is hot and soothing."; package packagel; public class IceWater implements Beverage { I public IceWater (int ounces, double price) { super (ounces, price); public String drink() { return "This ice water is cool and refreshing." } } package package2; static import java.lang. System.out; public class TestBeverage { public static void main(String[] myListofargs) { IceWater drinki = new IceWater (16, 1.00); Hot Tea drink2 = new Hot Tea (10, 2.99); out.print("The water is " + drinki.getOunces () + " ounces "); out.println("and costs $" + drinki.getPrice() + "."); out.println(drink1.drink()); out.print("The tea is " + drink2.getOunces() + " ounces "); out.println("and costs $" + drink2.getPrice () + " "); out.println(drink2.drink()); 1 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!