Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion src/main/java/core/basesyntax/MainApp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
package core.basesyntax;

public class MainApp {
abstract class Machine {
public abstract void doWork();
public abstract void stopWork();
}

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

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

class Bulldozer extends Machine {
@Override
public void doWork() {
System.out.println("Bulldozer has started working.");
}
@Override
public void stopWork() {
System.out.println("Bulldozer has stopped working.");
}
}
class Excavator extends Machine {
@Override
public void doWork() {
System.out.println("Excavator has started working.");
}
@Override
public void stopWork() {
System.out.println("Excavator has stopped working.");
}
}

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();
}
}
}
Loading