Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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