From 4bbd43e8b0c406f5fd7ea2043841095819e8437f Mon Sep 17 00:00:00 2001 From: Ihor Date: Sat, 19 Oct 2024 11:52:58 +0300 Subject: [PATCH 1/2] add solution --- src/main/java/core/basesyntax/Bulldozer.java | 13 +++++++++++++ src/main/java/core/basesyntax/Excavator.java | 13 +++++++++++++ src/main/java/core/basesyntax/Machine.java | 8 ++++++++ src/main/java/core/basesyntax/MainApp.java | 11 +++++++++++ src/main/java/core/basesyntax/Truck.java | 13 +++++++++++++ 5 files changed, 58 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..a2291d5f3 --- /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 started working"); + } + + @Override + public void stopWork() { + System.out.println("Bulldozed 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..418773a88 --- /dev/null +++ b/src/main/java/core/basesyntax/Excavator.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +public class Excavator extends Machine { + @Override + public void doWork() { + System.out.println("Excavator started working"); + } + + @Override + public void stopWork() { + System.out.println("Excavator 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..5b8bb3eb3 --- /dev/null +++ b/src/main/java/core/basesyntax/Machine.java @@ -0,0 +1,8 @@ +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..8641db0d9 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 { + 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/Truck.java b/src/main/java/core/basesyntax/Truck.java new file mode 100644 index 000000000..e3dc9a76e --- /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 trucking"); + } + + @Override + public void stopWork() { + System.out.println("Truck stopped trucking"); + } +} From 52b018b8f5c0f7014956eb5ac389b6683d1f60db Mon Sep 17 00:00:00 2001 From: Ihor Date: Sun, 20 Oct 2024 14:25:56 +0300 Subject: [PATCH 2/2] fixed style --- src/main/java/core/basesyntax/Machine.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/core/basesyntax/Machine.java b/src/main/java/core/basesyntax/Machine.java index 5b8bb3eb3..4219699a5 100644 --- a/src/main/java/core/basesyntax/Machine.java +++ b/src/main/java/core/basesyntax/Machine.java @@ -1,7 +1,6 @@ package core.basesyntax; public abstract class Machine { - public abstract void doWork(); public abstract void stopWork();