public class Computer {
public static void main(String[] args) {
Computer computer = new Computer();
}
public Computer(){
Keyboard keyboard = new Keyboard("New Keyboard");
Monitor monitor = new Monitor("New Monitor");
Mouse mouse = new Mouse("New Mouse");
SystemUnit systemUnit = new SystemUnit("New SystemUnit");
System.out.println(keyboard.getKeyboardInit());
System.out.println(monitor.getMonitorInit());
System.out.println(mouse.getMouseInit());
System.out.println(systemUnit.getSystemUnitItem());
}
}
public class Keyboard {
private final String keyboardInit;
public Keyboard(String keyboardInit) {
this.keyboardInit = keyboardInit;
}
public String getKeyboardInit() {
return keyboardInit;
}
}
код остальных классов такой же как Keyboard, все в разных классах.
не проходит:
В конструкторе класса Computer нужно создать 4 объекта разных "комплектующих".package com.javarush.task.pro.task10.task1020;
public class Computer {
public static void main(String[] args) {
Computer computer = new Computer();
}
public Computer(){
Keyboard keyboard = new Keyboard("New Keyboard");
Monitor monitor = new Monitor("New Monitor");
Mouse mouse = new Mouse("New Mouse");
SystemUnit systemUnit = new SystemUnit("New SystemUnit");
System.out.println(keyboard.getKeyboardInit());
System.out.println(monitor.getMonitorInit());
System.out.println(mouse.getMouseInit());
System.out.println(systemUnit.getSystemUnitItem());
}
}