From d6a70f1b70e24e0134f03493a33457ef84963f99 Mon Sep 17 00:00:00 2001 From: mykolatsupryk Date: Sun, 5 Nov 2023 20:57:37 +0200 Subject: [PATCH 1/3] solution opp task --- src/main/java/core/basesyntax/MainApp.java | 17 +++++++++++++++++ .../java/core/basesyntax/model/Bulldozer.java | 13 +++++++++++++ .../java/core/basesyntax/model/Excavator.java | 13 +++++++++++++ .../java/core/basesyntax/model/Machine.java | 8 ++++++++ src/main/java/core/basesyntax/model/Truck.java | 13 +++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 src/main/java/core/basesyntax/model/Bulldozer.java create mode 100644 src/main/java/core/basesyntax/model/Excavator.java create mode 100644 src/main/java/core/basesyntax/model/Machine.java create mode 100644 src/main/java/core/basesyntax/model/Truck.java diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index f99e9a019..8bf217692 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,22 @@ package core.basesyntax; +import core.basesyntax.model.Bulldozer; +import core.basesyntax.model.Excavator; +import core.basesyntax.model.Machine; +import core.basesyntax.model.Truck; + 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(); + } + } } diff --git a/src/main/java/core/basesyntax/model/Bulldozer.java b/src/main/java/core/basesyntax/model/Bulldozer.java new file mode 100644 index 000000000..c2fa8627a --- /dev/null +++ b/src/main/java/core/basesyntax/model/Bulldozer.java @@ -0,0 +1,13 @@ +package core.basesyntax.model; + +public class Bulldozer extends Machine{ + @Override + public void doWork() { + System.out.println("Bulldozer started work"); + } + + @Override + public void stopWork() { + System.out.println("Bulldozer stopped work"); + } +} diff --git a/src/main/java/core/basesyntax/model/Excavator.java b/src/main/java/core/basesyntax/model/Excavator.java new file mode 100644 index 000000000..89c5eb9ac --- /dev/null +++ b/src/main/java/core/basesyntax/model/Excavator.java @@ -0,0 +1,13 @@ +package core.basesyntax.model; + +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/model/Machine.java b/src/main/java/core/basesyntax/model/Machine.java new file mode 100644 index 000000000..6d7faee7a --- /dev/null +++ b/src/main/java/core/basesyntax/model/Machine.java @@ -0,0 +1,8 @@ +package core.basesyntax.model; + +public abstract class Machine { + + public abstract void doWork(); + + public abstract void stopWork(); +} diff --git a/src/main/java/core/basesyntax/model/Truck.java b/src/main/java/core/basesyntax/model/Truck.java new file mode 100644 index 000000000..887019856 --- /dev/null +++ b/src/main/java/core/basesyntax/model/Truck.java @@ -0,0 +1,13 @@ +package core.basesyntax.model; + +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 25f0ef7bea3c66c517202fe290f8d794e339417b Mon Sep 17 00:00:00 2001 From: mykolatsupryk Date: Sun, 5 Nov 2023 21:06:13 +0200 Subject: [PATCH 2/3] correct solution oop --- src/main/java/core/basesyntax/model/Bulldozer.java | 2 +- src/main/java/core/basesyntax/model/Excavator.java | 2 +- src/main/java/core/basesyntax/model/Truck.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/core/basesyntax/model/Bulldozer.java b/src/main/java/core/basesyntax/model/Bulldozer.java index c2fa8627a..fe740a701 100644 --- a/src/main/java/core/basesyntax/model/Bulldozer.java +++ b/src/main/java/core/basesyntax/model/Bulldozer.java @@ -1,6 +1,6 @@ package core.basesyntax.model; -public class Bulldozer extends Machine{ +public class Bulldozer extends Machine { @Override public void doWork() { System.out.println("Bulldozer started work"); diff --git a/src/main/java/core/basesyntax/model/Excavator.java b/src/main/java/core/basesyntax/model/Excavator.java index 89c5eb9ac..9ed080829 100644 --- a/src/main/java/core/basesyntax/model/Excavator.java +++ b/src/main/java/core/basesyntax/model/Excavator.java @@ -1,6 +1,6 @@ package core.basesyntax.model; -public class Excavator extends Machine{ +public class Excavator extends Machine { @Override public void doWork() { System.out.println("Excavator started work"); diff --git a/src/main/java/core/basesyntax/model/Truck.java b/src/main/java/core/basesyntax/model/Truck.java index 887019856..2341ffed5 100644 --- a/src/main/java/core/basesyntax/model/Truck.java +++ b/src/main/java/core/basesyntax/model/Truck.java @@ -1,6 +1,6 @@ package core.basesyntax.model; -public class Truck extends Machine{ +public class Truck extends Machine { @Override public void doWork() { System.out.println("Truck started work"); From 795935d01da5aba7c1a509955ab8793bab96e447 Mon Sep 17 00:00:00 2001 From: mykolatsupryk Date: Mon, 6 Nov 2023 15:14:37 +0200 Subject: [PATCH 3/3] removed blank lines --- src/main/java/core/basesyntax/MainApp.java | 1 - src/main/java/core/basesyntax/model/Machine.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index 8bf217692..c87964381 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -8,7 +8,6 @@ public class MainApp { public static void main(String[] args) { - Machine[] machines = { new Truck(), new Bulldozer(), diff --git a/src/main/java/core/basesyntax/model/Machine.java b/src/main/java/core/basesyntax/model/Machine.java index 6d7faee7a..4dc6fd081 100644 --- a/src/main/java/core/basesyntax/model/Machine.java +++ b/src/main/java/core/basesyntax/model/Machine.java @@ -1,7 +1,6 @@ package core.basesyntax.model; public abstract class Machine { - public abstract void doWork(); public abstract void stopWork();