diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index f99e9a019..1da187017 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,21 @@ package core.basesyntax; +import core.basesyntax.vehicle.Bulldozer; +import core.basesyntax.vehicle.Excavator; +import core.basesyntax.vehicle.Machine; +import core.basesyntax.vehicle.Truck; + public class MainApp { + public static void main(String[] args) { + Machine truck = new Truck(); + Machine bulldozer = new Bulldozer(); + Machine excavator = new Excavator(); + + Machine[] machines = new Machine[] {truck, bulldozer, excavator}; + for (Machine machine : machines) { + machine.doWork(); + machine.stopWork(); + } + } } diff --git a/src/main/java/core/basesyntax/vehicle/Bulldozer.java b/src/main/java/core/basesyntax/vehicle/Bulldozer.java new file mode 100644 index 000000000..23622306d --- /dev/null +++ b/src/main/java/core/basesyntax/vehicle/Bulldozer.java @@ -0,0 +1,13 @@ +package core.basesyntax.vehicle; + +public class Bulldozer extends Machine { + @Override + public void doWork() { + System.out.println("Bulldozer started its work"); + } + + @Override + public void stopWork() { + System.out.println("Bulldozer stopped its work"); + } +} diff --git a/src/main/java/core/basesyntax/vehicle/Excavator.java b/src/main/java/core/basesyntax/vehicle/Excavator.java new file mode 100644 index 000000000..1e9744744 --- /dev/null +++ b/src/main/java/core/basesyntax/vehicle/Excavator.java @@ -0,0 +1,13 @@ +package core.basesyntax.vehicle; + +public class Excavator extends Machine { + @Override + public void doWork() { + System.out.println("Excavator started its work"); + } + + @Override + public void stopWork() { + System.out.println("Excavator stopped its work"); + } +} diff --git a/src/main/java/core/basesyntax/vehicle/Machine.java b/src/main/java/core/basesyntax/vehicle/Machine.java new file mode 100644 index 000000000..0bd68df93 --- /dev/null +++ b/src/main/java/core/basesyntax/vehicle/Machine.java @@ -0,0 +1,7 @@ +package core.basesyntax.vehicle; + +public abstract class Machine { + public abstract void doWork(); + + public abstract void stopWork(); +} diff --git a/src/main/java/core/basesyntax/vehicle/Truck.java b/src/main/java/core/basesyntax/vehicle/Truck.java new file mode 100644 index 000000000..619dc714d --- /dev/null +++ b/src/main/java/core/basesyntax/vehicle/Truck.java @@ -0,0 +1,13 @@ +package core.basesyntax.vehicle; + +public class Truck extends Machine { + @Override + public void doWork() { + System.out.println("Truck started its work"); + } + + @Override + public void stopWork() { + System.out.println("Truck stopped its work"); + } +}