Question
JAVA Assume that you are creating a class which defines a Garment object. Your class has the following variables: private int garType; private int garColor;
JAVA Assume that you are creating a class which defines a Garment object. Your class has the following variables: private int garType; private int garColor;
a. Code the constructor for the Garment class which has two formal parameters whose values are assigned into the class variables.
b. Code a mutator method for the garType variable. c. Assume that the garType variable contains a 1 for shirt and a 2 for pants, no other values will be loaded into this variable. Likewise the garColor variable contains a 1, 2 or 3 for red, green and blue respectively. Code the toString method for the Garment class which returns a string of the form: color space type. For example if garType contains a 1 (for a shirt) and garColor contains a 2 (for green) the method should return: green shirt
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