Skip to content

Commit

Permalink
oop-basic
Browse files Browse the repository at this point in the history
  • Loading branch information
TarasYurkovskyi committed Jul 30, 2023
1 parent ea616af commit 0206266
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/main/java/core/basesyntax/Bulldozer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package core.basesyntax;

public class Bulldozer extends Machine {

@Override
public void doWork() {
System.out.println("Bulldozer starts working");
}

@Override
public void stopWork() {
System.out.println("Bulldozer stops working");
}
}
13 changes: 13 additions & 0 deletions src/main/java/core/basesyntax/Excavator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package core.basesyntax;

public class Excavator extends Machine {
@Override
public void doWork() {
System.out.println("Excavator starts working");
}

@Override
public void stopWork() {
System.out.println("Excavator stops working");
}
}
8 changes: 8 additions & 0 deletions src/main/java/core/basesyntax/Machine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package core.basesyntax;

public abstract class Machine {

public abstract void doWork();

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

public class MainApp {

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

public class Truck extends Machine {
@Override
public void doWork() {
System.out.println("Truck starts working");
}

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

0 comments on commit 0206266

Please sign in to comment.