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 01:00
)a grad student comes up with the following algorithm to sort an array a[1..n] that works by first sorting the first 2/3rds of the array, then sorting the last 2/3rds of the (resulting) array, and finally sorting the first 2/3rds of the new array. 1: function g-sort(a, n) . takes as input an array of n numbers, a[1..n] 2: g-sort-recurse(a, 1, n) 3: end function 4: function g-sort-recurse(a, `, u) 5: if u ⒠` ≤ 0 then 6: return . 1 or fewer elements already sorted 7: else if u ⒠` = 1 then . 2 elements 8: if a[u] < a[`] then . swap values 9: temp ↠a[u] 10: a[u] ↠a[`] 11: a[`] ↠temp 12: end if 13: else . 3 or more elements 14: size ↠u ⒠` + 1 15: twothirds ↠d(2 ◠size)/3e 16: g-sort-recurse(a, `, ` + twothirds ⒠1) 17: g-sort-recurse(a, u ⒠twothirds + 1, u) 18: g-sort-recurse(a, `, ` + twothirds ⒠1) 19: end if 20: end function first (5 pts), prove that the algorithm correctly sorts the numbers in the array (in increasing order). after showing that it correctly sorts 1 and 2 element intervals, you may make the (incorrect) assumption that the number of elements being passed to g-sort-recurse is always a multiple of 3 to simplify the notation (and drop the floors/ceilings).
Answers: 3
question
Computers and Technology, 23.06.2019 07:00
What are three software programs for mobile computing?
Answers: 1
question
Computers and Technology, 23.06.2019 15:10
What role did women fill during world war ii?
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
Monica and her team have implemented is successfully in an organization. what factor leads to successful is implementation? good between different departments in an organization leads to successful is implementation.
Answers: 1
You know the right answer?
Class TShirt{ private String colour;
private int size;

public TShirt(String s, in...
Questions
question
History, 24.08.2019 07:50
question
Mathematics, 24.08.2019 07:50
question
Mathematics, 24.08.2019 07:50
Questions on the website: 13722359