forked from Unified-Logic-Development-Team/ConsoleGameHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
30 lines (28 loc) · 801 Bytes
/
Game.java
File metadata and controls
30 lines (28 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Optional;
/**
* Interface representing a generic game in the arcade.
* @version 1
*/
interface Game {
/**
* Returns the name of the game.
* @return game name
*/
String getName();
/**
* Starts and runs the game.
*
* This method returns an Optional<Integer> to represent the score
* achieved by the player.
* <pre>
* Games that track a numeric score return Optional.of(score).
* Games that do not use scoring return Optional.empty().
*
* This approach avoids the ambiguity of using 0 to mean "no score",
* since 0 can be a valid score in many games.
* </pre>
* @return Optional containing score if applicable, or
* Optional.empty() if not
*/
Optional<Integer> play();
}