Question
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
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. Once you fix all the errors provide me with the output for the program.
Below is the source code for all four files:
package package1;
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 package1;
public class IceWater implements Beverage {
public IceWater(int ounces, double price) {
super(ounces, price);
}
public String drink() {
return "This ice water is cool and refreshing.";
}
}
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 package2;
static import java.lang.System.out;
public class TestBeverage {
public static void main(String[] myListOfArgs) {
IceWater drink1 = new IceWater(16, 1.00);
HotTea drink2 = new HotTea(10, 2.99);
out.print("The water is " + drink1.getOunces() + " ounces ");
out.println("and costs $" + drink1.getPrice() + ".");
out.println(drink1.drink());
out.print("The tea is " + drink2.getOunces() + " ounces ");
out.println("and costs $" + drink2.getPrice() + ".");
out.println(drink2.drink());
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started