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 59769bb commit b2eaef4
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 82 deletions.
13 changes: 13 additions & 0 deletions src/main/java/core/basesyntax/Bulldozer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package core.basesyntax;

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

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");
}
}
7 changes: 7 additions & 0 deletions src/main/java/core/basesyntax/Machine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package core.basesyntax;

abstract class Machine {
public abstract void doWork();

public abstract void stopWork();
}
122 changes: 40 additions & 82 deletions src/main/java/core/basesyntax/MainApp.java
Original file line number Diff line number Diff line change
@@ -1,86 +1,44 @@
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();
}
}
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();
}
}
}
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;

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

0 comments on commit b2eaef4

Please sign in to comment.