diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java new file mode 100644 index 000000000..30a93a529 --- /dev/null +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +public class Bulldozer extends Machine { + @Override + public void doWork() { + System.out.println("Bulldozer started working"); + } + + @Override + public void stopWork() { + System.out.println("Bulldozer finished working"); + } +} diff --git a/src/main/java/core/basesyntax/Excavator.java b/src/main/java/core/basesyntax/Excavator.java new file mode 100644 index 000000000..c67c7b45f --- /dev/null +++ b/src/main/java/core/basesyntax/Excavator.java @@ -0,0 +1,12 @@ +package core.basesyntax; + +public class Excavator extends Machine { + @Override + public void doWork() { + System.out.println("Excavator started working"); + } + @Override + public void stopWork() { + System.out.println("Excavator finished working"); + } +} diff --git a/src/main/java/core/basesyntax/Machine.java b/src/main/java/core/basesyntax/Machine.java new file mode 100644 index 000000000..92ac7d520 --- /dev/null +++ b/src/main/java/core/basesyntax/Machine.java @@ -0,0 +1,8 @@ +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..54cf62a18 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,16 @@ package core.basesyntax; public class MainApp { + public static void main(String[] args) { + Machine excavator = new Excavator(); + Machine bulldozer = new Bulldozer(); + Machine truck = new Truck(); + Machine[] machines = new Machine[] {excavator, bulldozer, truck}; + + 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..8249e62b8 --- /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 working"); + } + + @Override + public void stopWork() { + System.out.println("Truck finished working"); + } +}