Graderpractice for programmers

Back to 254275 OOP - Labs 1-5 Review

N. T-shirts ✰

Problem

A t-shirt has a size and a colour. Complete the TShirt class by writing 3 methods:

  • getSize returns the size as a char (S, M, L, X)
  • getColour returns the colour of the t-shirt

Submit the TShirt.java file ONLY!

Template:
class TShirt {
    private char size;
    private String colour;

    public TShirt(char size, String colour) {
        this.size = size;
        this.colour = colour;
    }
}
Test code:
class TestE {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char size = sc.nextLine().charAt(0);
        String colour = sc.nextLine();
        TShirt fav = new TShirt(size, colour);
        System.out.println("My favorite t-shirt is size " + fav.getSize() + " and " + fav.getColour());
    }
}

Examples

Input

M
blue

Output

My favorite t-shirt is size M and blue

Input

S
pink

Output

My favorite t-shirt is size S and pink

Submit your solution

java