Computers and Technology

Class TShirt{ private String colour;
private int size;

public TShirt(String s, int n){
colour = s;
/* to be implemented in part (a)*/
}

public String getColour(){
return colour;
}

public int getSize(){
return size;
}

/
* if the shirt has a positive size, reduce the
* size by 1. If the size is 0, no change.
/
public void shrinkShirt(){
/* to be implemented in part */
}
}

Write a line of code that declares a new variable named ledZeppelin of type TShirt and initializes it to refer to a new TShirt with colour "black" and size 5.

Finish implementing the method shrinkShirt().

Suppose s1 and s2 are properly initialized variables of type TShirt. Write a code segment that prints "Identical" if the shirts are the same colour and the same size, "Uniform" if they are the same colour but not the same size, "Fits" if they are the same size but not the same colour, and "Different" if they are different sizes and different colours.

if(colour == size ){

}

Suppose s1 and s2 are properly initialized variables of type TShirt. Write a code segment that, if the shirts are the same colour and their sizes differ by exactly one, it shrinks the larger shirt by one size.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:30, Metlife
You are new to microsoft certification and want to start out by getting a certification geared around windows 8. what microsoft certification should you pursue?
Answers: 1
image
Computers and Technology, 24.06.2019 20:20, isaiahromero15
Write python code that prompts the user to enter his or her favorite color and assigns the user’s input to a variable named color.
Answers: 1
image
Computers and Technology, 25.06.2019 05:50, jonmorton159
Acolor class has three public, integer-returning accessor methods: getred, getgreen, and getblue, and three protected, void-returning mutator methods: setred, setgreen, setblue, each of which accepts an integer parameter and assigns it to the corresponding color component. the class, alphachannelcolor-- a subclass of color-- has an integer instance variable, alpha, containing the alpha channel value, representing the degree of transparency of the color. alphachannelcolor also has a method named dissolve (void-returning, and no parameters), that causes the color to fade a bit. it does this by incrementing (by 1) all three color components (using the above accessor and mutator methods) as well as the alpha component value. write the dissolve method.
Answers: 2
image
Computers and Technology, 25.06.2019 08:40, drealtania21
Anyone took cgs 1060 and took exam for simnet, slide 50 question on 1st exam.
Answers: 3
Do you know the correct answer?
Class TShirt{ private String colour;
private int size;

public TShirt(String s, in...

Questions in other subjects:

Konu
Geography, 03.03.2021 23:20
Konu
English, 03.03.2021 23:20