subject

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.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:00
Discuss the ways in which electronic information associated with payments is addressed in terms of security. include encryption, secure sockets layers, and secure electronic transactions in your discussion. are there any other ways that consumers and businesses can keep their payment information secure in an electronic commerce environment? do you feel that your information is safe when conducting electronic business? why or why not?
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
If you add the following to the query grid in an access query, what is it called? salestaxamt: [salestaxrate]*[totalsale] formula calculated field total calculation
Answers: 2
question
Computers and Technology, 24.06.2019 18:30
What is the local portion of the e-mail address below? [email protected] a.) @ b.) biz c.) gumchewer d.) twrigley
Answers: 1
question
Computers and Technology, 24.06.2019 20:30
Which key should you press to leave the cell as it originally was? a. delete b. cancel c. backspace d. enter
Answers: 1
You know the right answer?
Class TShirt{ private String colour;
private int size;

public TShirt(String s, in...
Questions
question
Mathematics, 01.04.2020 21:45
Questions on the website: 13722367