Graderpractice for programmers

Back to 254275 OOP - Labs 6-10 Review

3. Add getTypeDescription() method

Problem

Reuse your Printer class from question 2. Add a method named getTypeDescription that returns "laser", "inkjet", "thermal" as a String for the type description.

Test code:

class MT2cTask3 {
    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        Printer p = input();

        System.out.println(p.getFullName() + " is a " + p.getTypeDescription() + " printer");
    }

    private static Printer input() {
        String brand = sc.nextLine();
        String model = sc.nextLine();
        char type = sc.nextLine().charAt(0);
        boolean colour = sc.nextLine().equalsIgnoreCase("C");
        int price = Integer.parseInt(sc.nextLine());
        return new Printer(brand, model, type, colour, price);
    }
}

Examples

Input

Canon
G2000
i
C
4800

Output

Canon G2000 is a inkjet printer

Input

HP
Deskjet 200
t
B
2200

Output

HP Deskjet 200 is a thermal printer

Submit your solution

java