Skip to content

Commit

Permalink
add new files code
Browse files Browse the repository at this point in the history
  • Loading branch information
Volikk committed Oct 20, 2024
1 parent 8f084d8 commit 1024ddb
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/main/java/core/basesyntax/Bulldozer.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package core.basesyntax;

public class Bulldozer {
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.");
}
}
11 changes: 10 additions & 1 deletion src/main/java/core/basesyntax/Excavator.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package core.basesyntax;

public class Excavator {
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.");
}
}
5 changes: 4 additions & 1 deletion src/main/java/core/basesyntax/Machine.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package core.basesyntax;

public class Machine {
abstract class Machine {
public abstract void doWork();

public abstract void stopWork();
}
8 changes: 7 additions & 1 deletion src/main/java/core/basesyntax/MainApp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package core.basesyntax;

public class MainApp {

public static void main(String[] args) {
Machine[] machines = { new Truck(), new Bulldozer(), new Excavator() };
for (Machine machine : machines) {
machine.doWork();
machine.stopWork();
}
}
}
11 changes: 10 additions & 1 deletion src/main/java/core/basesyntax/Truck.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package core.basesyntax;

public class Truck {
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.");
}
}

0 comments on commit 1024ddb

Please sign in to comment.