Graderpractice for programmers

Back to 254275 OOP - Labs 6-10 Review

2. Add getFullName() method

Problem

Reuse your Printer class from question 1. Add a method named getFullName() that returns the brand and the model (separated by a space).

Test code:

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

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

        System.out.println(p.getFullName());
    }

    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
4500

Output

Canon G2000

Submit your solution

java