diff --git a/src/main/java/core/basesyntax/Machine.java b/src/main/java/core/basesyntax/Machine.java new file mode 100644 index 000000000..7900ea90e --- /dev/null +++ b/src/main/java/core/basesyntax/Machine.java @@ -0,0 +1,7 @@ +package core.basesyntax; + +public abstract class Machine { + public abstract void doWork(); + public abstract void stopWork(); +} + diff --git a/src/main/java/core/basesyntax/Machines.java b/src/main/java/core/basesyntax/Machines.java new file mode 100644 index 000000000..13ef6ec07 --- /dev/null +++ b/src/main/java/core/basesyntax/Machines.java @@ -0,0 +1,40 @@ +package core.basesyntax; + +public abstract class Machines { + public static class Truck extends Machine { + @Override + public void doWork() { + System.out.println("Truck started its work"); + } + @Override + public void stopWork() { + System.out.println("Truck stopped working"); + } + } + + public static class Bulldozer extends Machine { + @Override + public void doWork() { + System.out.println("Bulldozer started its work"); + } + @Override + public void stopWork() { + System.out.println("Bulldozer stopped working"); + } + } + + public static class Excavator extends Machine { + @Override + public void doWork() { + System.out.println("Excavator started its work"); + } + @Override + public void stopWork() { + System.out.println("Excavator stopped working"); + } + } + + +} + + diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index f99e9a019..980b23272 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,20 @@ package core.basesyntax; public class MainApp { + public static void main (String[] args) { + Machine[] machines = { + new Machines.Truck(), + new Machines.Bulldozer(), + new Machines.Excavator() + }; + + for(Machine machine : machines) { + machine.doWork(); + } + + for(Machine machine : machines) { + machine.stopWork(); + } + } }