Question: Lab Description : Write a Cup class that will simulate storing liquid in a cup. You can add to the cup and pour from the

Lab Description : Write a Cup class that will simulate storing liquid in a cup. You can add to the cup and pour from the cup.
Sample Runner Code :
System.out.println( "made a cup of 10");
Cup c = new Cup(10);
System.out.println( "amt in cup "+ c.getAmtInCup()); //returns amt in the cup
System.out.println( "add "+ c.add(5)); //adds amt and returns overflow
System.out.println( "amt in cup "+ c.getAmtInCup()); //returns amt in the cup
System.out.println( "add "+ c.add(2)); //adds amt and returns overflow
System.out.println( "num adds "+ c.getNumAdds()); //returns the number of adds
System.out.println("is full "+ c.isFull()); //checks if the cup is full
System.out.println( "will overflow 10"+ c.willOverflow(10)); //checks to the see if
//adding the amount will
//cause an overflow
System.out.println( "pour 7"); //pours out an amt from the cup
c.pour(7);
System.out.println( "amt in cup "+ c.getAmtInCup()); //returns amt in the cup
System.out.println("is full "+ c.isFull()); //checks to the if the cup is full
Sample Output :
made a cup of 10
amt in cup 0.0
add 0.0
amt in cup 5.0
add 0.0
num adds 2
is full false
will overflow 10 true
pour 7
amt in cup 0.0
is full false

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!