From e986095e69863c28460346b365a72a830347426e Mon Sep 17 00:00:00 2001 From: Taras Markov Date: Sun, 10 Nov 2024 11:27:48 -0500 Subject: [PATCH] Add machines --- src/main/java/core/basesyntax/MainApp.java | 13 ++++++++++++- .../java/core/basesyntax/machines/Bulldozer.java | 13 +++++++++++++ .../java/core/basesyntax/machines/Excavator.java | 13 +++++++++++++ .../java/core/basesyntax/machines/Machine.java | 6 ++++++ src/main/java/core/basesyntax/machines/Truck.java | 14 ++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/main/java/core/basesyntax/machines/Bulldozer.java create mode 100644 src/main/java/core/basesyntax/machines/Excavator.java create mode 100644 src/main/java/core/basesyntax/machines/Machine.java create mode 100644 src/main/java/core/basesyntax/machines/Truck.java diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index f99e9a019..25c8c0e8f 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 { +import core.basesyntax.machines.Bulldozer; +import core.basesyntax.machines.Excavator; +import core.basesyntax.machines.Machine; +import core.basesyntax.machines.Truck; +public class MainApp { + static Machine[] machines = new Machine[]{new Bulldozer(), new Excavator(), new Truck()}; + public static void main(String[] args) { + for (int i = 0; i < 3; i++){ + machines[i].doWork(); + machines[i].stopWork(); + } + } } diff --git a/src/main/java/core/basesyntax/machines/Bulldozer.java b/src/main/java/core/basesyntax/machines/Bulldozer.java new file mode 100644 index 000000000..de854eb6e --- /dev/null +++ b/src/main/java/core/basesyntax/machines/Bulldozer.java @@ -0,0 +1,13 @@ +package core.basesyntax.machines; + +public class Bulldozer extends Machine { + @Override + public void doWork() { + System.out.println("Bulldozer is working"); + } + + @Override + public void stopWork() { + System.out.println("Bulldozer stop"); + } +} diff --git a/src/main/java/core/basesyntax/machines/Excavator.java b/src/main/java/core/basesyntax/machines/Excavator.java new file mode 100644 index 000000000..891ebe788 --- /dev/null +++ b/src/main/java/core/basesyntax/machines/Excavator.java @@ -0,0 +1,13 @@ +package core.basesyntax.machines; + +public class Excavator extends Machine { + @Override + public void doWork() { + System.out.println("Excavator is work"); + } + + @Override + public void stopWork() { + System.out.println("Excavator stop"); + } +} diff --git a/src/main/java/core/basesyntax/machines/Machine.java b/src/main/java/core/basesyntax/machines/Machine.java new file mode 100644 index 000000000..4e5f37fc2 --- /dev/null +++ b/src/main/java/core/basesyntax/machines/Machine.java @@ -0,0 +1,6 @@ +package core.basesyntax.machines; + +public abstract class Machine { + public abstract void doWork(); + public abstract void stopWork(); +} diff --git a/src/main/java/core/basesyntax/machines/Truck.java b/src/main/java/core/basesyntax/machines/Truck.java new file mode 100644 index 000000000..34e578e59 --- /dev/null +++ b/src/main/java/core/basesyntax/machines/Truck.java @@ -0,0 +1,14 @@ +package core.basesyntax.machines; + +public class Truck extends Machine { + + @Override + public void doWork() { + System.out.println("Truck is working"); + } + + @Override + public void stopWork() { + System.out.println("Truck stop"); + } +}