diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java new file mode 100644 index 000000000..4a8b0583c --- /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(this.getClass().getSimpleName() + " does the Work!"); + } + + @Override + public void stopWork() { + System.out.println(this.getClass().getSimpleName() + " stops the 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..fdc02d749 --- /dev/null +++ b/src/main/java/core/basesyntax/Excavator.java @@ -0,0 +1,12 @@ +package core.basesyntax; + +public class Excavator extends Machine{ + @Override + public void doWork() { + System.out.println(this.getClass().getSimpleName() + " does the Work!"); + } + @Override + public void stopWork() { + System.out.println(this.getClass().getSimpleName() + " stops the 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..d1cee61cb --- /dev/null +++ b/src/main/java/core/basesyntax/Machine.java @@ -0,0 +1,6 @@ +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..137aa2e15 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[] array = new Machine[] { new Bulldozer(), new Truck(), new Excavator()}; + for(Machine m : array){ + m.doWork(); + m.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..50c936c78 --- /dev/null +++ b/src/main/java/core/basesyntax/Truck.java @@ -0,0 +1,12 @@ +package core.basesyntax; + +public class Truck extends Machine{ + @Override + public void doWork() { + System.out.println(this.getClass().getSimpleName() + " does the Work!"); + } + @Override + public void stopWork() { + System.out.println(this.getClass().getSimpleName() + " stops the Work!"); + } +}