From df290dda5468db2062cfd85dd726efc06f0a0ab2 Mon Sep 17 00:00:00 2001 From: Pavlo Sukhanko Date: Tue, 24 Sep 2024 19:21:19 +0100 Subject: [PATCH 1/4] all classes and loop is created --- src/main/java/core/basesyntax/Bulldozer.java | 15 +++++++++++++++ src/main/java/core/basesyntax/Excavator.java | 15 +++++++++++++++ src/main/java/core/basesyntax/Machine.java | 7 +++++++ src/main/java/core/basesyntax/MainApp.java | 15 +++++++++++++++ src/main/java/core/basesyntax/Truck.java | 16 ++++++++++++++++ 5 files changed, 68 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..91ae719e8 --- /dev/null +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -0,0 +1,15 @@ +package core.basesyntax; + +public class Bulldozer extends Machine{ + @Override + public void doWork() { + System.out.println("Bulldozer machine started its work."); + } + + @Override + public void stopWork() { + + System.out.println("Bulldozer machines 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..11facec59 --- /dev/null +++ b/src/main/java/core/basesyntax/Excavator.java @@ -0,0 +1,15 @@ +package core.basesyntax; + +public class Excavator extends Machine { + @Override + public void doWork() { + System.out.println("Excavator machine started its work."); + } + + @Override + public void stopWork() { + + System.out.println("Excavator machines 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..ba5fb14a3 --- /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..d38800c60 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -2,4 +2,19 @@ public class MainApp { + public static void main(String[] args) { + + Machine[] machines = new Machine[]{ + new Bulldozer(), new Truck(), new Excavator() + }; + + for (int i = 0; i < machines.length; i++) { + + machines[i].doWork(); + machines[i].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..c31c5ffef --- /dev/null +++ b/src/main/java/core/basesyntax/Truck.java @@ -0,0 +1,16 @@ +package core.basesyntax; + +public class Truck extends Machine { + @Override + public void doWork() { + + System.out.println("Truck machine started its work."); + } + + @Override + public void stopWork() { + + System.out.println("Truck machines stopped working"); + + } +} From 8053fc8f33f1cb39e630c6619ad615212660e795 Mon Sep 17 00:00:00 2001 From: Pavlo Sukhanko Date: Tue, 24 Sep 2024 19:23:54 +0100 Subject: [PATCH 2/4] did some change in loop --- src/main/java/core/basesyntax/MainApp.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index d38800c60..dfb88a1dc 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -8,10 +8,10 @@ public static void main(String[] args) { new Bulldozer(), new Truck(), new Excavator() }; - for (int i = 0; i < machines.length; i++) { + for (Machine machine : machines) { - machines[i].doWork(); - machines[i].stopWork(); + machine.doWork(); + machine.stopWork(); } From 1b445191b98bc36107da9504a083e5161217ff57 Mon Sep 17 00:00:00 2001 From: Pavlo Sukhanko Date: Tue, 24 Sep 2024 19:29:28 +0100 Subject: [PATCH 3/4] change code style --- src/main/java/core/basesyntax/Bulldozer.java | 2 +- src/main/java/core/basesyntax/Machine.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java index 91ae719e8..7d08c8405 100644 --- a/src/main/java/core/basesyntax/Bulldozer.java +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -1,6 +1,6 @@ package core.basesyntax; -public class Bulldozer extends Machine{ +public class Bulldozer extends Machine { @Override public void doWork() { System.out.println("Bulldozer machine started its work."); diff --git a/src/main/java/core/basesyntax/Machine.java b/src/main/java/core/basesyntax/Machine.java index ba5fb14a3..b3cde4819 100644 --- a/src/main/java/core/basesyntax/Machine.java +++ b/src/main/java/core/basesyntax/Machine.java @@ -4,4 +4,5 @@ public abstract class Machine { public abstract void doWork(); public abstract void stopWork(); + } From 630a4cd04698f731b41f2e7108c2d061bd8e51f0 Mon Sep 17 00:00:00 2001 From: Pavlo Sukhanko Date: Tue, 24 Sep 2024 19:30:23 +0100 Subject: [PATCH 4/4] change code style --- src/main/java/core/basesyntax/Machine.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/core/basesyntax/Machine.java b/src/main/java/core/basesyntax/Machine.java index b3cde4819..1265fc00a 100644 --- a/src/main/java/core/basesyntax/Machine.java +++ b/src/main/java/core/basesyntax/Machine.java @@ -3,6 +3,7 @@ public abstract class Machine { public abstract void doWork(); + public abstract void stopWork(); }