forked from Unified-Logic-Development-Team/ConsoleGameHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnakeGame.java
More file actions
28 lines (26 loc) · 835 Bytes
/
SnakeGame.java
File metadata and controls
28 lines (26 loc) · 835 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
import java.util.Optional;
/**
* A simplified console version of the classic Snake game.
* The player controls a "snake" that moves around a grid, collecting food
* and growing in length.
* The game ends if the snake runs into itself or the edge of the grid.
* <pre>
* Simulate the game board with a 2D array.
* Display the game using text-based output.
* </pre>
* @version 1
*/
class SnakeGame implements Game {
@Override
public String getName() {
return "Snake";
}
@Override
public Optional<Integer> play() {
System.out.println("Welcome to Snake!");
System.out.println("Objective: Survive as long as you can!");
System.out.println("How to play: Grow by eating dots and avoid walls");
System.out.println("or you die");
return Optional.empty();
}
}