From 8209df227d304c26e66a195f49eb7607e3c0be56 Mon Sep 17 00:00:00 2001 From: dzxd16 Date: Sun, 8 Dec 2024 01:17:29 +0200 Subject: [PATCH 1/3] Create new classes --- src/main/java/core/basesyntax/Bulldozer.java | 13 +++++++++++++ src/main/java/core/basesyntax/Excavator.java | 13 +++++++++++++ src/main/java/core/basesyntax/Machine.java | 6 ++++++ src/main/java/core/basesyntax/Main.java | 13 +++++++++++++ src/main/java/core/basesyntax/MainApp.java | 5 ----- src/main/java/core/basesyntax/Truck.java | 13 +++++++++++++ 6 files changed, 58 insertions(+), 5 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/Main.java delete mode 100644 src/main/java/core/basesyntax/MainApp.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..cb3ac8817 --- /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..478891986 --- /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..5a62715c2 --- /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/Main.java b/src/main/java/core/basesyntax/Main.java new file mode 100644 index 000000000..f83daac5d --- /dev/null +++ b/src/main/java/core/basesyntax/Main.java @@ -0,0 +1,13 @@ +package core.basesyntax; + +public class Main { + public static void main(String[] args) { + + Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; + for( Machine mash : machines ) { + mash.doWork(); + mash.stopWork(); + } + + } +} \ No newline at end of file diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java deleted file mode 100644 index f99e9a019..000000000 --- a/src/main/java/core/basesyntax/MainApp.java +++ /dev/null @@ -1,5 +0,0 @@ -package core.basesyntax; - -public class MainApp { - -} diff --git a/src/main/java/core/basesyntax/Truck.java b/src/main/java/core/basesyntax/Truck.java new file mode 100644 index 000000000..23a362093 --- /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"); + } +} From 65736ea4a00c48a3fc09d146f297e03d6e5c1d51 Mon Sep 17 00:00:00 2001 From: dzxd16 Date: Sun, 8 Dec 2024 11:34:53 +0200 Subject: [PATCH 2/3] Create new classes, second --- src/main/java/core/basesyntax/Bulldozer.java | 4 ++-- src/main/java/core/basesyntax/Excavator.java | 4 ++-- src/main/java/core/basesyntax/Machine.java | 3 +++ src/main/java/core/basesyntax/Main.java | 14 +++++++------- src/main/java/core/basesyntax/Truck.java | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/core/basesyntax/Bulldozer.java b/src/main/java/core/basesyntax/Bulldozer.java index cb3ac8817..d95121c0c 100644 --- a/src/main/java/core/basesyntax/Bulldozer.java +++ b/src/main/java/core/basesyntax/Bulldozer.java @@ -2,12 +2,12 @@ public class Bulldozer extends Machine{ @Override - public void doWork() { + public void doWork(){ System.out.println("Bulldozer started its work"); } @Override - public void stopWork() { + 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 index 478891986..50cb183c5 100644 --- a/src/main/java/core/basesyntax/Excavator.java +++ b/src/main/java/core/basesyntax/Excavator.java @@ -2,12 +2,12 @@ public class Excavator extends Machine{ @Override - public void doWork() { + public void doWork(){ System.out.println("Excavator started its work"); } @Override - public void stopWork() { + 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 index 5a62715c2..6f92f9553 100644 --- a/src/main/java/core/basesyntax/Machine.java +++ b/src/main/java/core/basesyntax/Machine.java @@ -1,6 +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 index f83daac5d..b022317b0 100644 --- a/src/main/java/core/basesyntax/Main.java +++ b/src/main/java/core/basesyntax/Main.java @@ -1,13 +1,13 @@ package core.basesyntax; public class Main { - public static void main(String[] args) { + public static void main(String[] args){ - Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; - for( Machine mash : machines ) { - mash.doWork(); - mash.stopWork(); + Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; + for ( Machine mash : machines ) { + mash.doWork(); + mash.stopWork(); + } } - } -} \ No newline at end of file +} diff --git a/src/main/java/core/basesyntax/Truck.java b/src/main/java/core/basesyntax/Truck.java index 23a362093..37e9b77ee 100644 --- a/src/main/java/core/basesyntax/Truck.java +++ b/src/main/java/core/basesyntax/Truck.java @@ -2,12 +2,12 @@ public class Truck extends Machine{ @Override - public void doWork() { + public void doWork(){ System.out.println("Truck started its work"); } @Override - public void stopWork() { + public void stopWork(){ System.out.println("Truck stopped working"); } } From a4554bceb5c60589b925552416a2ca9006453108 Mon Sep 17 00:00:00 2001 From: dzxd16 Date: Sun, 8 Dec 2024 11:51:12 +0200 Subject: [PATCH 3/3] add mainApp class --- src/main/java/core/basesyntax/Main.java | 10 ++++------ src/main/java/core/basesyntax/MainApp.java | 12 ++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 src/main/java/core/basesyntax/MainApp.java diff --git a/src/main/java/core/basesyntax/Main.java b/src/main/java/core/basesyntax/Main.java index b022317b0..e763b7216 100644 --- a/src/main/java/core/basesyntax/Main.java +++ b/src/main/java/core/basesyntax/Main.java @@ -3,11 +3,9 @@ public class Main { public static void main(String[] args){ - Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; - for ( Machine mash : machines ) { - mash.doWork(); - mash.stopWork(); - } + MainApp mainApp = new MainApp(); + mainApp.testing(); } - } + + diff --git a/src/main/java/core/basesyntax/MainApp.java b/src/main/java/core/basesyntax/MainApp.java new file mode 100644 index 000000000..8ab884894 --- /dev/null +++ b/src/main/java/core/basesyntax/MainApp.java @@ -0,0 +1,12 @@ +package core.basesyntax; + +public class MainApp { + + public void testing(){ + Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; + for ( Machine mash : machines ) { + mash.doWork(); + mash.stopWork(); + } + } +}