diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java new file mode 100644 index 000000000..7f58b4db9 --- /dev/null +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -0,0 +1,14 @@ +package core.basesyntax; + +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/Excavator.java b/src/main/java/core/basesyntax/Excavator.java new file mode 100644 index 000000000..5e4f2d0dd --- /dev/null +++ b/src/main/java/core/basesyntax/Excavator.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +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/Machine.java b/src/main/java/core/basesyntax/Machine.java new file mode 100644 index 000000000..6f92f9553 --- /dev/null +++ b/src/main/java/core/basesyntax/Machine.java @@ -0,0 +1,9 @@ +package core.basesyntax; + +public abstract class Machine { + + public abstract void doWork(); + + public abstract void stopWork(); + +} diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index f99e9a019..4d7b2ca72 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -2,4 +2,17 @@ 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/Truck.java b/src/main/java/core/basesyntax/Truck.java new file mode 100644 index 000000000..277f964aa --- /dev/null +++ b/src/main/java/core/basesyntax/Truck.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +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."); + } +}