-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
23 lines (18 loc) · 779 Bytes
/
Game.java
File metadata and controls
23 lines (18 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public abstract class Game { // loops through a set of games and returns the result
protected AllGamesRecord allRecords;
public Game() { //constructor
this.allRecords = new AllGamesRecord();
}
public AllGamesRecord playAll() { // plays a set of games and records results.
while (playNext()) {
printInstructions();
GameRecord gameRecord = play();
allRecords.add(gameRecord);
}
return allRecords;
}
// prints game instructions
public abstract void printInstructions();
public abstract GameRecord play(); // plays one game. To be implemented by subclasses.
public abstract boolean playNext(); // checks if the next game should be played. To be implemented by subclasses.
}