forked from On-Time-Software-Developers/ConsoleGameHub-OSD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicTacToeGame.java
More file actions
36 lines (34 loc) · 1.01 KB
/
TicTacToeGame.java
File metadata and controls
36 lines (34 loc) · 1.01 KB
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
31
32
33
34
35
36
import java.util.Optional;
/**
* A classic 3x3 two-player game adapted for single-player mode
* against the computer.
* The player and the computer take turns marking Xs and Os on a grid.
* The winner is the first to align three in a row (horizontally,
* vertically, or diagonally).
* <pre>
* Implementation may be a basic AI using heuristics or
* an unbeatable strategy using the Minimax algorithm.
* </pre>
* @version 2
*/
public class TicTacToeGame implements Game {
/**
*Returns the name of the game.
*@return the game name.
*/
public String getName() {
return "Tic-Tac-Toe";
}
/**
*Displays the game instructions and returns empty result.
*@return an empty Optional.
**/
public Optional<Integer> play() {
System.out.println("Welcome to Tic-Tac-Toe!.");
System.out.println("Objective: Be the first to get 3 of your "
+ "marks in a row.");
System.out.println("How to play: Take turns placing X or O "
+ "on the 3x3 grid.");
return Optional.empty();
}
}