diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java new file mode 100644 index 000000000..54582ec11 --- /dev/null +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -0,0 +1,23 @@ +package core.basesyntax; + +public class Bulldozer extends Machine { + @Override + public void doWork() { + System.out.println("The truck has started to shallow digging and ditching; " + + "short-range transportation of material; " + + "spreading soil dumped from trucks; " + + "rough grading; " + + "removing trees, stumps, and boulders; " + + "and cleaning and leveling around loading equipment."); + } + + @Override + public void stopWork() { + System.out.println("The truck has stopped to shallow digging and ditching; " + + "short-range transportation of material; " + + "spreading soil dumped from trucks; " + + "rough grading; " + + "removing trees, stumps, and boulders; " + + "and cleaning and leveling around loading equipment."); + } +} diff --git a/src/main/java/core/basesyntax/Excavator.java b/src/main/java/core/basesyntax/Excavator.java new file mode 100644 index 000000000..3c889d421 --- /dev/null +++ b/src/main/java/core/basesyntax/Excavator.java @@ -0,0 +1,15 @@ +package core.basesyntax; + +public class Excavator extends Machine { + @Override + public void doWork() { + System.out.println("The excavator has started digging trenches " + + "and breaking holes to lifting away waste and excavating mines."); + } + + @Override + public void stopWork() { + System.out.println("The excavator has stopped digging trenches " + + "and breaking holes to lifting away waste and excavating mines."); + } +} diff --git a/src/main/java/core/basesyntax/Machine.java b/src/main/java/core/basesyntax/Machine.java new file mode 100644 index 000000000..cad5be453 --- /dev/null +++ b/src/main/java/core/basesyntax/Machine.java @@ -0,0 +1,7 @@ +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..79847efbf 100644 --- a/src/main/java/core/basesyntax/MainApp.java +++ b/src/main/java/core/basesyntax/MainApp.java @@ -1,5 +1,16 @@ package core.basesyntax; public class MainApp { + public static void main(String[] args) { + Machine excavator = new Excavator(); + Machine truck = new Truck(); + Machine bulldozer = new Bulldozer(); + Machine[] machines = {excavator, truck, bulldozer}; + + 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..614005c55 --- /dev/null +++ b/src/main/java/core/basesyntax/Truck.java @@ -0,0 +1,15 @@ +package core.basesyntax; + +public class Truck extends Machine { + @Override + public void doWork() { + System.out.println("The truck has started to transport freight," + + " carry specialized payloads, or perform other utilitarian work."); + } + + @Override + public void stopWork() { + System.out.println("The truck has stopped to transport freight," + + " carry specialized payloads and perform other utilitarian work."); + } +}