Question: Write a class called Cup that contains the following information: 1. Private instance variables for the size of the cup (either 8, 16 or 32

 Write a class called Cup that contains the following information: 1.

Write a class called Cup that contains the following information: 1. Private instance variables for the size of the cup (either 8, 16 or 32 ounces (Int)), and the contents of the cup (String) (such as "soda" or "water" or any string). 2. A two-argument constructor to set each of the instance variables above. If the size of the cup is not 8, 16 or 32, throw an IllegalArgumentException stating the argument that is not correct. 3. Get and Set methods for each instance variable with the same error detection as the constructor. public class Cup

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!