Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need a program made for what is in the pictures and this is the sample usage. Thank you! public class TestGlass { public static
I need a program made for what is in the pictures and this is the sample usage. Thank you!
public class TestGlass
{
public static void main(String [] args)
{
Glass milk = new Glass(15); // 15 ounces of milk
Glass juice = new Glass(3); // 3 ources of juice
milk.drink(2);
milk.drink(1);
milk.report();
juice.fill(6); // went from 3 to 9 ounces
juice.drink(1); // now down to 8 ounces
juice.report();
juice.spill();
juice.report();
}
}
class Glass
{
// Declare a variable to keep track of the number of ounces in a glass here
// Write the methods here. You will need a constructor, plus the drink, report, fill,
// and spill methods. These methods are for any generic glass -- they are not specific
// to the milk or juice instances of a glass (i.e., you should not mention "juice" or
// "milk" inside the Glass class).
}
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