Skip to content

Commit

Permalink
Home Work
Browse files Browse the repository at this point in the history
  • Loading branch information
Obusker committed Oct 22, 2023
1 parent 57f404c commit 59769bb
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions src/main/java/core/basesyntax/MainApp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,86 @@
package core.basesyntax;

abstract class Machine {
public abstract void doWork();

public abstract void stopWork();
}

abstract class Bulldozer extends Machine {
@Override
public void doWork() {
System.out.println("Truck started its work");
}

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

abstract class Truck extends Machine {
@Override
public void doWork() {
System.out.println("Bulldozer started its work");
}

@Override
public void stopWork() {
System.out.println("Bulldozer stopped its work");
}
}

abstract class Excavator extends Machine {
@Override
public void doWork() {
System.out.println("Excavator started its work");
}

@Override
public void stopWork() {
System.out.println("Excavator stopped its work");
}
}

public class MainApp {
public static void main(String[] args) {
Machine bulldozer = new Bulldozer() {
@Override
public void doWork() {
super.doWork();
}

@Override
public void stopWork() {
super.stopWork();
}
};
Machine truck = new Truck() {
@Override
public void doWork() {
super.doWork();
}

@Override
public void stopWork() {
super.stopWork();
}
};
Machine excavator = new Excavator() {
@Override
public void doWork() {
super.doWork();
}

@Override
public void stopWork() {
super.stopWork();
}
};
Machine[] machines = {bulldozer, truck, excavator};
for (Machine machine : machines) {
machine.doWork();
machine.stopWork();
}
}
}

0 comments on commit 59769bb

Please sign in to comment.