From 2f768b1bd103314dbb3fc14c5cae1f313065248c Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 4 Aug 2023 17:55:34 +0200 Subject: [PATCH] Erik Loskorikh done --- src/main/java/core/basesyntax/Bulldozer.java | 14 +++++++++++++- src/main/java/core/basesyntax/Excavator.java | 13 ++++++++++++- src/main/java/core/basesyntax/Machine.java | 7 ++++++- src/main/java/core/basesyntax/MainApp.java | 8 +++++++- src/main/java/core/basesyntax/Truck.java | 13 ++++++++++++- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java index e4db09e03..e9e2ec4db 100644 --- a/src/main/java/core/basesyntax/Bulldozer.java +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -1,2 +1,14 @@ -package core.basesyntax;public class Bulldozer { +package core.basesyntax; + +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.\n"); + } } diff --git a/src/main/java/core/basesyntax/Excavator.java b/src/main/java/core/basesyntax/Excavator.java index dc76194bd..f58983d4a 100644 --- a/src/main/java/core/basesyntax/Excavator.java +++ b/src/main/java/core/basesyntax/Excavator.java @@ -1,2 +1,13 @@ -package core.basesyntax;public class Excavator { +package core.basesyntax; + +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.\n"); + } } diff --git a/src/main/java/core/basesyntax/Machine.java b/src/main/java/core/basesyntax/Machine.java index 006d239a4..cad5be453 100644 --- a/src/main/java/core/basesyntax/Machine.java +++ b/src/main/java/core/basesyntax/Machine.java @@ -1,2 +1,7 @@ -package core.basesyntax;public class Machine { +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..f9046dc2e 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,11 @@ package core.basesyntax; public class MainApp { - + public static void main(String[] args) { + Machine[] machines = {new Bulldozer(), new Excavator(), new Truck()}; + for (Machine m : machines) { + m.doWork(); + m.stopWork(); + } + } } diff --git a/src/main/java/core/basesyntax/Truck.java b/src/main/java/core/basesyntax/Truck.java index 44a9f82c6..da54c87ee 100644 --- a/src/main/java/core/basesyntax/Truck.java +++ b/src/main/java/core/basesyntax/Truck.java @@ -1,2 +1,13 @@ -package core.basesyntax;public class Truck { +package core.basesyntax; + +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.\n"); + } }