From 2ce38583747fe85b8bf3ac2acdf68413c31f90e3 Mon Sep 17 00:00:00 2001 From: Andreyepam Date: Wed, 19 Jul 2023 17:29:41 +0300 Subject: [PATCH 1/2] Homework1/OOP_Basic is ready --- src/main/java/core/basesyntax/MainApp.java | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index f99e9a019..cb42071eb 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,54 @@ package core.basesyntax; +abstract class Machine { + public abstract void doWork(); + public abstract void stopWork(); +} + +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"); + } +} + +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"); + } +} + +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[] machines = {new Truck(), new Bulldozer(), new Excavator()}; + for (Machine machine : machines) { + machine.doWork(); + machine.stopWork(); + } + } } + + From 66558b131e80617af1d876d8719289de5a0ff87f Mon Sep 17 00:00:00 2001 From: Andreyepam Date: Wed, 19 Jul 2023 17:45:48 +0300 Subject: [PATCH 2/2] move file --- 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 | 40 -------------------- src/main/java/core/basesyntax/Truck.java | 13 +++++++ 5 files changed, 46 insertions(+), 40 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..3755ef452 --- /dev/null +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +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/Excavator.java b/src/main/java/core/basesyntax/Excavator.java new file mode 100644 index 000000000..955be54c5 --- /dev/null +++ b/src/main/java/core/basesyntax/Excavator.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +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 cb42071eb..e99a9f44e 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,45 +1,5 @@ package core.basesyntax; -abstract class Machine { - public abstract void doWork(); - public abstract void stopWork(); -} - -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"); - } -} - -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"); - } -} - -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[] machines = {new Truck(), new Bulldozer(), new Excavator()}; diff --git a/src/main/java/core/basesyntax/Truck.java b/src/main/java/core/basesyntax/Truck.java new file mode 100644 index 000000000..59b697129 --- /dev/null +++ b/src/main/java/core/basesyntax/Truck.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +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"); + } +}