diff --git a/src/main/java/core/basesyntax/Application.java b/src/main/java/core/basesyntax/Application.java index 855c745..29f285f 100644 --- a/src/main/java/core/basesyntax/Application.java +++ b/src/main/java/core/basesyntax/Application.java @@ -7,10 +7,13 @@ public static void main(String[] args) { Engine engine = new Engine(); engine.setModel("V12"); engine.setManufactureDate(new Date()); + Car car = new Car(); car.setEngine(engine); + Car carClone = car.clone(); carClone.getEngine().setModel("V8"); + System.out.println(car); System.out.println(carClone); } diff --git a/src/main/java/core/basesyntax/Car.java b/src/main/java/core/basesyntax/Car.java index bd28166..fd734b2 100644 --- a/src/main/java/core/basesyntax/Car.java +++ b/src/main/java/core/basesyntax/Car.java @@ -1,8 +1,44 @@ package core.basesyntax; public class Car implements Cloneable { + private String id; + private String model; + private int price; + private String color; private Engine engine; + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public int getPrice() { + return price; + } + + public void setPrice(int price) { + this.price = price; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + public Engine getEngine() { return engine; } @@ -24,8 +60,8 @@ public Car clone() { @Override public String toString() { - return "Car{" + - "engine=" + engine + - '}'; + return "Car{" + + "id='" + id + '\'' + ", model='" + model + '\'' + ", price=" + price + + ", color='" + color + '\'' + ", engine=" + engine + '}'; } } diff --git a/src/main/java/core/basesyntax/Engine.java b/src/main/java/core/basesyntax/Engine.java index 1125647..8e1da5d 100644 --- a/src/main/java/core/basesyntax/Engine.java +++ b/src/main/java/core/basesyntax/Engine.java @@ -3,9 +3,20 @@ import java.util.Date; public class Engine implements Cloneable { + private String id; private String model; + private String type; + private int price; private Date manufactureDate; + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public String getModel() { return model; } @@ -14,6 +25,22 @@ public void setModel(String model) { this.model = model; } + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int getPrice() { + return price; + } + + public void setPrice(int price) { + this.price = price; + } + public Date getManufactureDate() { return manufactureDate; } @@ -33,9 +60,8 @@ public Engine clone() { @Override public String toString() { - return "Engine{" + - "model='" + model + '\'' + - ", manufactureDate=" + manufactureDate + - '}'; + return "Engine{" + + "id='" + id + '\'' + ", model='" + model + '\'' + ", type='" + type + '\'' + + ", price=" + price + ", manufactureDate=" + manufactureDate + '}'; } }