generated from mate-academy/jv-homework-template
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c81ce0
commit 9c66808
Showing
5 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} |