diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java new file mode 100644 index 000000000..d95121c0c --- /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 its work"); + } + + @Override + public void stopWork(){ + System.out.println("Bulldozer 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..50cb183c5 --- /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 its work"); + } + + @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..6f92f9553 --- /dev/null +++ b/src/main/java/core/basesyntax/Machine.java @@ -0,0 +1,9 @@ +package core.basesyntax; + +public abstract class Machine { + + public abstract void doWork(); + + public abstract void stopWork(); + +} diff --git a/src/main/java/core/basesyntax/Main.java b/src/main/java/core/basesyntax/Main.java new file mode 100644 index 000000000..e763b7216 --- /dev/null +++ b/src/main/java/core/basesyntax/Main.java @@ -0,0 +1,11 @@ +package core.basesyntax; + +public class Main { + public static void main(String[] args){ + + MainApp mainApp = new MainApp(); + mainApp.testing(); + } +} + + diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java index f99e9a019..8ab884894 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -2,4 +2,11 @@ public class MainApp { + public void testing(){ + Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; + for ( Machine mash : machines ) { + mash.doWork(); + mash.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..37e9b77ee --- /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 its work"); + } + + @Override + public void stopWork(){ + System.out.println("Truck stopped working"); + } +}