From e183476683a04f39c3a8db090d3ebb713d60e551 Mon Sep 17 00:00:00 2001 From: Maks Date: Fri, 27 Sep 2024 10:53:16 +0200 Subject: [PATCH] First solution --- src/main/java/core/basesyntax/Bulldozer.java | 13 +++++++++++++ src/main/java/core/basesyntax/Excavator.java | 13 +++++++++++++ src/main/java/core/basesyntax/Machine.java | 6 ++++++ src/main/java/core/basesyntax/MainApp.java | 7 +++++++ src/main/java/core/basesyntax/Truck.java | 13 +++++++++++++ 5 files changed, 52 insertions(+) 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..896566782 --- /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 stopped 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..0798c6527 --- /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 working"); + } + + @Override + public void stopWork() { + System.out.println("Excavator stopped 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..b3c81d24e --- /dev/null +++ b/src/main/java/core/basesyntax/Machine.java @@ -0,0 +1,6 @@ +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..4dfbc446c 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,12 @@ package core.basesyntax; public class MainApp { + public static void main(String[] args){ + Machine[] machines = {new Truck(),new Excavator(), new Bulldozer()}; + 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..b9b56e92a --- /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 stopped working"); + } +}