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 ;
Cup c new Cup;
System.out.println "amt in cup cgetAmtInCup; returns amt in the cup
System.out.println "add cadd; adds amt and returns overflow
System.out.println "amt in cup cgetAmtInCup; returns amt in the cup
System.out.println "add cadd; adds amt and returns overflow
System.out.println "num adds cgetNumAdds; returns the number of adds
System.out.printlnis full cisFull; checks if the cup is full
System.out.println "will overflow cwillOverflow; checks to the see if
adding the amount will
cause an overflow
System.out.println "pour ; pours out an amt from the cup
cpour;
System.out.println "amt in cup cgetAmtInCup; returns amt in the cup
System.out.printlnis full cisFull; checks to the if the cup is full
Sample Output :
made a cup of
amt in cup
add
amt in cup
add
num adds
is full false
will overflow true
pour
amt in cup
is full false
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
