From 6b85e6a98d1021159b820bf2971a4b01a5675af4 Mon Sep 17 00:00:00 2001 From: DmitryShmerchuk Date: Mon, 2 Dec 2024 15:46:25 +0200 Subject: [PATCH 1/4] Ready --- src/main/java/core/basesyntax/Bulldozer.java | 13 +++++++++++++ src/main/java/core/basesyntax/Excavator.java | 12 ++++++++++++ src/main/java/core/basesyntax/Machine.java | 6 ++++++ src/main/java/core/basesyntax/MainApp.java | 8 ++++++++ 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..2d52f1f31 --- /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 start work!"); + } + + @Override + public void stopWork() { + System.out.println("Bulldozer stopped 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..434f90b21 --- /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 work!"); + } + public void stopWork() { + System.out.println("Excavator stopped 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..5a62715c2 --- /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..8a11ebc16 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,13 @@ 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..2f0b34447 --- /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 work!"); + } + + @Override + public void stopWork() { + System.out.println("Truck stopped work!"); + } +} From ab90c0d162bbc6727d86f884d7fac282767bb6ee Mon Sep 17 00:00:00 2001 From: DmitryShmerchuk Date: Mon, 2 Dec 2024 15:56:34 +0200 Subject: [PATCH 2/4] Ready --- src/main/java/core/basesyntax/Bulldozer.java | 4 ++-- src/main/java/core/basesyntax/Excavator.java | 5 +++-- src/main/java/core/basesyntax/MainApp.java | 12 +++++------- src/main/java/core/basesyntax/Truck.java | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java index 2d52f1f31..c2aee296f 100644 --- a/src/main/java/core/basesyntax/Bulldozer.java +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -1,9 +1,9 @@ package core.basesyntax; -public class Bulldozer extends Machine{ +public class Bulldozer extends Machine { @Override public void doWork() { - System.out.println("Bulldozer start work!"); + System.out.println("Bulldozer started work!"); } @Override diff --git a/src/main/java/core/basesyntax/Excavator.java b/src/main/java/core/basesyntax/Excavator.java index 434f90b21..1219cacee 100644 --- a/src/main/java/core/basesyntax/Excavator.java +++ b/src/main/java/core/basesyntax/Excavator.java @@ -1,11 +1,12 @@ package core.basesyntax; -public class Excavator extends Machine{ - +public class Excavator extends Machine { @Override public void doWork() { System.out.println("Excavator started work!"); } + + @Override public void stopWork() { System.out.println("Excavator stopped work!"); } diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index 8a11ebc16..70d551a77 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -2,12 +2,10 @@ 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(); + 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 index 2f0b34447..fbd4fa263 100644 --- a/src/main/java/core/basesyntax/Truck.java +++ b/src/main/java/core/basesyntax/Truck.java @@ -1,13 +1,13 @@ package core.basesyntax; -public class Truck extends Machine{ +public class Truck extends Machine { @Override public void doWork() { System.out.println("Truck started work!"); } @Override - public void stopWork() { + public void stopWork() { System.out.println("Truck stopped work!"); } } From 311afed52e3841cbfc248834166894b390a917f9 Mon Sep 17 00:00:00 2001 From: DmitryShmerchuk Date: Mon, 2 Dec 2024 16:29:44 +0200 Subject: [PATCH 3/4] Fixed --- src/main/java/core/basesyntax/MainApp.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index 70d551a77..bec136661 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -5,7 +5,8 @@ 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 +} From a34768b3aaa8c0c2dcb02f88b0de9505fb6c5f07 Mon Sep 17 00:00:00 2001 From: DmitryShmerchuk Date: Mon, 2 Dec 2024 16:33:42 +0200 Subject: [PATCH 4/4] Fixed_2 --- 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 5a62715c2..cad5be453 100644 --- a/src/main/java/core/basesyntax/Machine.java +++ b/src/main/java/core/basesyntax/Machine.java @@ -2,5 +2,6 @@ public abstract class Machine { public abstract void doWork(); + public abstract void stopWork(); }