forked from Unified-Logic-Development-Team/ConsoleGameHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLightsOutGame.java
More file actions
30 lines (28 loc) · 1.01 KB
/
LightsOutGame.java
File metadata and controls
30 lines (28 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
import java.util.Optional;
/**
* A logic puzzle where each cell on a grid can be either "on" or "off".
* Selecting a cell toggles it and its immediate neighbors.
* The goal is to turn all the lights off in as few moves as possible.
* <pre>
* Consider a model using a grid of booleans.
* Implement toggling logic on that grid.
* </pre>
* @version 1
*/
class LightsOutGame implements Game {
@Override
public String getName() {
return "Lights Out";
}
@Override
public Optional<Integer> play() {
System.out.println("Welcome to Lights Out!");
System.out.println("The tiles have an 'on' or 'off' function.");
System.out.println("Selecting a tile will change its state.");
System.out.println("Tiles also change the state of neighboring tiles.");
System.out.println("Turning them 'off' or 'on' as well.");
System.out.println("Grid must be lit in as few turns as possible.");
System.out.println("Good luck!");
return Optional.empty();
}
}