From f5dd2522d613b8a1f22c52bd78a15cda7f1a8b12 Mon Sep 17 00:00:00 2001 From: Oleksandr Beztsennyi Date: Tue, 19 Sep 2023 14:46:00 +0300 Subject: [PATCH] fineshed project --- src/main/java/core/basesyntax/Bulldozer.java | 12 ++++++++++++ src/main/java/core/basesyntax/Excavator.java | 12 ++++++++++++ src/main/java/core/basesyntax/Machine.java | 7 +++++++ src/main/java/core/basesyntax/MainApp.java | 10 ++++++++-- src/main/java/core/basesyntax/Truck.java | 12 ++++++++++++ 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/main/java/core/basesyntax/Bulldozer.java create mode 100644 src/main/java/core/basesyntax/Excavator.java create mode 100644 src/main/java/core/basesyntax/Machine.java create mode 100644 src/main/java/core/basesyntax/Truck.java diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java new file mode 100644 index 000000000..a8b886aac --- /dev/null +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -0,0 +1,12 @@ +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..3b6212238 --- /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 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..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/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index f99e9a019..70d551a77 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,11 @@ package core.basesyntax; public class MainApp { - -} + public static void main(String[] args) { + Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; + for (Machine machine : machines) { + machine.doWork(); + machine.stopWork(); + } + } +} \ No newline at end of file diff --git a/src/main/java/core/basesyntax/Truck.java b/src/main/java/core/basesyntax/Truck.java new file mode 100644 index 000000000..a58f0e81e --- /dev/null +++ b/src/main/java/core/basesyntax/Truck.java @@ -0,0 +1,12 @@ +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"); + } +}