From b2eaef4a26b31ef3d23bffcd8af110620b69e45a Mon Sep 17 00:00:00 2001 From: Obusker Date: Sun, 22 Oct 2023 21:30:17 +0300 Subject: [PATCH] Home Work --- src/main/java/core/basesyntax/Bulldozer.java | 13 ++ src/main/java/core/basesyntax/Excavator.java | 13 ++ src/main/java/core/basesyntax/Machine.java | 7 ++ src/main/java/core/basesyntax/MainApp.java | 122 ++++++------------- src/main/java/core/basesyntax/Truck.java | 13 ++ 5 files changed, 86 insertions(+), 82 deletions(-) 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..5ea82fbd1 --- /dev/null +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +abstract class Bulldozer extends Machine { + @Override + public void doWork() { + System.out.println("Truck started its work"); + } + + @Override + public void stopWork() { + System.out.println("Truck stopped its 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..9f6ad500d --- /dev/null +++ b/src/main/java/core/basesyntax/Excavator.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +abstract 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/Machine.java b/src/main/java/core/basesyntax/Machine.java new file mode 100644 index 000000000..474d05768 --- /dev/null +++ b/src/main/java/core/basesyntax/Machine.java @@ -0,0 +1,7 @@ +package core.basesyntax; + +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 076b31ea9..d9e999433 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,86 +1,44 @@ package core.basesyntax; -abstract class Machine { - public abstract void doWork(); - - public abstract void stopWork(); -} - -abstract class Bulldozer extends Machine { - @Override - public void doWork() { - System.out.println("Truck started its work"); - } - - @Override - public void stopWork() { - System.out.println("Truck stopped its work"); - } -} - -abstract class Truck extends Machine { - @Override - public void doWork() { - System.out.println("Bulldozer started its work"); - } - - @Override - public void stopWork() { - System.out.println("Bulldozer stopped its work"); - } -} - -abstract 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"); - } -} - public class MainApp { - public static void main(String[] args) { - Machine bulldozer = new Bulldozer() { - @Override - public void doWork() { - super.doWork(); - } - - @Override - public void stopWork() { - super.stopWork(); - } - }; - Machine truck = new Truck() { - @Override - public void doWork() { - super.doWork(); - } - - @Override - public void stopWork() { - super.stopWork(); - } - }; - Machine excavator = new Excavator() { - @Override - public void doWork() { - super.doWork(); - } - - @Override - public void stopWork() { - super.stopWork(); - } - }; - Machine[] machines = {bulldozer, truck, excavator}; - for (Machine machine : machines) { - machine.doWork(); - machine.stopWork(); - } - } + public static void main(String[] args) { + Machine bulldozer = new Bulldozer() { + @Override + public void doWork() { + super.doWork(); + } + + @Override + public void stopWork() { + super.stopWork(); + } + }; + Machine truck = new Truck() { + @Override + public void doWork() { + super.doWork(); + } + + @Override + public void stopWork() { + super.stopWork(); + } + }; + Machine excavator = new Excavator() { + @Override + public void doWork() { + super.doWork(); + } + + @Override + public void stopWork() { + super.stopWork(); + } + }; + Machine[] machines = {bulldozer, truck, 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..19e275266 --- /dev/null +++ b/src/main/java/core/basesyntax/Truck.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +abstract class Truck extends Machine { + @Override + public void doWork() { + System.out.println("Bulldozer started its work"); + } + + @Override + public void stopWork() { + System.out.println("Bulldozer stopped its work"); + } +}