Skip to content

Commit

Permalink
Added Machine, added Truck, Bulldozer, and Excavator that inherit fro…
Browse files Browse the repository at this point in the history
…m Machine. Call doWork and stopWork
  • Loading branch information
acidcor committed Dec 12, 2024
1 parent f7fa9c0 commit f2b5ea8
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 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 do work");
}

@Override
public void stopWork() {
System.out.println("Bulldozer stop work");
}
}
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 do work");
}

@Override
public void stopWork() {
System.out.println("Excavator stop work");
}
}
4 changes: 3 additions & 1 deletion src/main/java/core/basesyntax/Machine.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package core.basesyntax;

public class Machine {
public abstract class Machine {
public abstract void doWork();
public abstract void stopWork();
}
12 changes: 12 additions & 0 deletions src/main/java/core/basesyntax/MainApp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
package core.basesyntax;

public class MainApp {
public static void main(String[] args) {
Machine[] machines = {
new Bulldozer(),
new Excavator(),
new Truck()
};

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 do work");
}

@Override
public void stopWork() {
System.out.println("Truck stop work");
}
}

0 comments on commit f2b5ea8

Please sign in to comment.