Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroBorysenko2004 authored Oct 30, 2024
1 parent 0c81ce0 commit 9c66808
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Machine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
abstract class Machine {
public abstract void doWork();

public abstract void stopWork();
}

10 changes: 10 additions & 0 deletions buldozer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Buldozer extends Machine {
public void doWork() {
System.out.println("The Buldozer started working.");
}

public void stopWork() {
System.out.println("The Buldozer stopped working.");
}
}

9 changes: 9 additions & 0 deletions excavator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Excavator extends Machine {
public void doWork() {
System.out.println("The Excavator started working.");
}

public void stopWork() {
System.out.println("The Excavator stopped working.");
}
}
9 changes: 9 additions & 0 deletions main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Main {
public static void main(String[] args) {
Machine[] machines = {new Truck(), new Buldozer(), new Excavator()};
for (int i = 0; i < machines.length; i++) {
machines[i].doWork();
machines[i].stopWork();
}
}
}
9 changes: 9 additions & 0 deletions truck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Truck extends Machine {
public void doWork() {
System.out.println("The Truck started working.");
}

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

0 comments on commit 9c66808

Please sign in to comment.