From 8a74c0a6c9888733f4b9aeebb50e7abe91f4f69f Mon Sep 17 00:00:00 2001 From: Roman Yuzviak <3romanyuzviak@gmail.com> Date: Thu, 10 Aug 2023 23:06:47 +0300 Subject: [PATCH 1/3] created all classes --- .../java/core/basesyntax/vehicle/Bulldozer.java | 13 +++++++++++++ .../java/core/basesyntax/vehicle/Excavator.java | 13 +++++++++++++ src/main/java/core/basesyntax/vehicle/Machine.java | 7 +++++++ src/main/java/core/basesyntax/vehicle/Truck.java | 14 ++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 src/main/java/core/basesyntax/vehicle/Bulldozer.java create mode 100644 src/main/java/core/basesyntax/vehicle/Excavator.java create mode 100644 src/main/java/core/basesyntax/vehicle/Machine.java create mode 100644 src/main/java/core/basesyntax/vehicle/Truck.java diff --git a/src/main/java/core/basesyntax/vehicle/Bulldozer.java b/src/main/java/core/basesyntax/vehicle/Bulldozer.java new file mode 100644 index 000000000..12085ae6a --- /dev/null +++ b/src/main/java/core/basesyntax/vehicle/Bulldozer.java @@ -0,0 +1,13 @@ +package core.basesyntax.vehicle; + +public class Bulldozer extends Machine{ + @Override + public void doWork() { + System.out.println("Bulldozer started its work.."); + } + + @Override + public void stopWork() { + System.out.println("Bulldozer stopped its work"); + } +} diff --git a/src/main/java/core/basesyntax/vehicle/Excavator.java b/src/main/java/core/basesyntax/vehicle/Excavator.java new file mode 100644 index 000000000..f36fcc0f5 --- /dev/null +++ b/src/main/java/core/basesyntax/vehicle/Excavator.java @@ -0,0 +1,13 @@ +package core.basesyntax.vehicle; + +public class Excavator extends Machine { + @Override + public void doWork() { + System.out.println("Excavator started its work.."); + } + + @Override + public void stopWork() { + System.out.println("Excavator stopped its work"); + } +} diff --git a/src/main/java/core/basesyntax/vehicle/Machine.java b/src/main/java/core/basesyntax/vehicle/Machine.java new file mode 100644 index 000000000..0bd68df93 --- /dev/null +++ b/src/main/java/core/basesyntax/vehicle/Machine.java @@ -0,0 +1,7 @@ +package core.basesyntax.vehicle; + +public abstract class Machine { + public abstract void doWork(); + + public abstract void stopWork(); +} diff --git a/src/main/java/core/basesyntax/vehicle/Truck.java b/src/main/java/core/basesyntax/vehicle/Truck.java new file mode 100644 index 000000000..4018acb88 --- /dev/null +++ b/src/main/java/core/basesyntax/vehicle/Truck.java @@ -0,0 +1,14 @@ +package core.basesyntax.vehicle; + +public class Truck extends Machine{ + @Override + public void doWork() { + System.out.println("Truck started its work.."); + } + + @Override + public void stopWork() { + System.out.println("Truck stopped its work"); + } + +} From a7294e69f6984b612b3f87e8a32d250aa39da71d Mon Sep 17 00:00:00 2001 From: Roman Yuzviak <3romanyuzviak@gmail.com> Date: Thu, 10 Aug 2023 23:59:25 +0300 Subject: [PATCH 2/3] finished/added code to MainApp class --- src/main/java/core/basesyntax/MainApp.java | 17 +++++++++++++++++ .../java/core/basesyntax/vehicle/Bulldozer.java | 4 ++-- .../java/core/basesyntax/vehicle/Excavator.java | 2 +- .../java/core/basesyntax/vehicle/Truck.java | 4 ++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index f99e9a019..90a2b8b2d 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.vehicle.Bulldozer; +import core.basesyntax.vehicle.Excavator; +import core.basesyntax.vehicle.Machine; +import core.basesyntax.vehicle.Truck; + public class MainApp { + public static void main(String[] args) { + Machine truck = new Truck(); + Machine bulldozer = new Bulldozer(); + Machine excavator = new Excavator(); + + Machine[] machines = new Machine[] {truck, bulldozer, excavator}; + for (Machine machine : machines) { + machine.doWork(); + machine.stopWork(); + } + } } + diff --git a/src/main/java/core/basesyntax/vehicle/Bulldozer.java b/src/main/java/core/basesyntax/vehicle/Bulldozer.java index 12085ae6a..23622306d 100644 --- a/src/main/java/core/basesyntax/vehicle/Bulldozer.java +++ b/src/main/java/core/basesyntax/vehicle/Bulldozer.java @@ -1,9 +1,9 @@ package core.basesyntax.vehicle; -public class Bulldozer extends Machine{ +public class Bulldozer extends Machine { @Override public void doWork() { - System.out.println("Bulldozer started its work.."); + System.out.println("Bulldozer started its work"); } @Override diff --git a/src/main/java/core/basesyntax/vehicle/Excavator.java b/src/main/java/core/basesyntax/vehicle/Excavator.java index f36fcc0f5..1e9744744 100644 --- a/src/main/java/core/basesyntax/vehicle/Excavator.java +++ b/src/main/java/core/basesyntax/vehicle/Excavator.java @@ -3,7 +3,7 @@ public class Excavator extends Machine { @Override public void doWork() { - System.out.println("Excavator started its work.."); + System.out.println("Excavator started its work"); } @Override diff --git a/src/main/java/core/basesyntax/vehicle/Truck.java b/src/main/java/core/basesyntax/vehicle/Truck.java index 4018acb88..7f832ffe5 100644 --- a/src/main/java/core/basesyntax/vehicle/Truck.java +++ b/src/main/java/core/basesyntax/vehicle/Truck.java @@ -1,9 +1,9 @@ package core.basesyntax.vehicle; -public class Truck extends Machine{ +public class Truck extends Machine { @Override public void doWork() { - System.out.println("Truck started its work.."); + System.out.println("Truck started its work"); } @Override From e875322189382502e21175eea5207444686a7941 Mon Sep 17 00:00:00 2001 From: Roman Yuzviak <3romanyuzviak@gmail.com> Date: Fri, 11 Aug 2023 10:08:52 +0300 Subject: [PATCH 3/3] fixed redutant empty lines --- src/main/java/core/basesyntax/MainApp.java | 1 - src/main/java/core/basesyntax/vehicle/Truck.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 90a2b8b2d..1da187017 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -19,4 +19,3 @@ public static void main(String[] args) { } } } - diff --git a/src/main/java/core/basesyntax/vehicle/Truck.java b/src/main/java/core/basesyntax/vehicle/Truck.java index 7f832ffe5..619dc714d 100644 --- a/src/main/java/core/basesyntax/vehicle/Truck.java +++ b/src/main/java/core/basesyntax/vehicle/Truck.java @@ -10,5 +10,4 @@ public void doWork() { public void stopWork() { System.out.println("Truck stopped its work"); } - }