Skip to content

Commit c3687a0

Browse files
committed
Improve console game and extend README
1 parent 344c20f commit c3687a0

File tree

4 files changed

+69
-3
lines changed

4 files changed

+69
-3
lines changed

README.md

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
```
2+
Welcome to
23
.----------------. .----------------. .----------------. .----------------. .----------------. .----------------.
34
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
45
| | _______ | || | _____ _____ | || | ________ | || | ____ | || | ___ ____ | || | _____ _____ | |
@@ -21,5 +22,41 @@ mvn package
2122
# Run console game
2223

2324
```shell script
24-
mvn clean package
25+
java -jar target/sudoku.jar
2526
```
27+
28+
Game looks like:
29+
30+
```text
31+
Width: 3
32+
Height: 3
33+
Level (1=easy, 2=medium, 3=hard): 2
34+
Creating puzzle...
35+
╔═╤═╤═╦═╤═╤═╦═╤═╤═╗
36+
║ │ │ ║ │ │7║ │ │ ║
37+
╟─┼─┼─╫─┼─┼─╫─┼─┼─╢
38+
║ │ │ ║ │ │ ║ │ │ ║
39+
╟─┼─┼─╫─┼─┼─╫─┼─┼─╢
40+
║ │ │ ║ │2│1║ │ │6║
41+
╠═╪═╪═╬═╪═╪═╬═╪═╪═╣
42+
║ │8│ ║ │ │2║ │5│ ║
43+
╟─┼─┼─╫─┼─┼─╫─┼─┼─╢
44+
║ │ │ ║ │ │8║3│ │ ║
45+
╟─┼─┼─╫─┼─┼─╫─┼─┼─╢
46+
║ │ │ ║7│ │ ║ │ │ ║
47+
╠═╪═╪═╬═╪═╪═╬═╪═╪═╣
48+
║ │ │2║ │4│ ║ │6│8║
49+
╟─┼─┼─╫─┼─┼─╫─┼─┼─╢
50+
║7│ │8║ │1│9║ │ │5║
51+
╟─┼─┼─╫─┼─┼─╫─┼─┼─╢
52+
║ │ │ ║ │7│ ║ │ │ ║
53+
╚═╧═╧═╩═╧═╧═╩═╧═╧═╝
54+
55+
Columns: right to left, 1 to 9
56+
Lines: top to bottom, 1 to 9
57+
Values: 1 to 9
58+
Type in 'SOLVE' to solve the puzzle
59+
Column: _
60+
Line: _
61+
Value: _
62+
```

pom.xml

+14
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@
4040
<artifactId>maven-surefire-plugin</artifactId>
4141
<version>2.22.0</version>
4242
</plugin>
43+
44+
<plugin>
45+
<!-- https://stackoverflow.com/a/9689877 -->
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-jar-plugin</artifactId>
48+
<version>3.2.0</version>
49+
<configuration>
50+
<archive>
51+
<manifest>
52+
<mainClass>de.borisskert.sudoku.console.Application</mainClass>
53+
</manifest>
54+
</archive>
55+
</configuration>
56+
</plugin>
4357
</plugins>
4458
</build>
4559
</project>

src/main/java/de/borisskert/sudoku/console/Application.java

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public class Application {
77
private static final Scanner scanner = new Scanner(System.in);
88

99
public static void main(String[] args) {
10+
printWelcomeMessage();
11+
1012
int width = readWidth();
1113
int height = readHeight();
1214
Level level = readLevel();
@@ -61,4 +63,19 @@ private static Level readLevel() {
6163

6264
return Level.from(level);
6365
}
66+
67+
private static void printWelcomeMessage() {
68+
System.out.println("Welcome to");
69+
System.out.println(" .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. \n" +
70+
"| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |\n" +
71+
"| | _______ | || | _____ _____ | || | ________ | || | ____ | || | ___ ____ | || | _____ _____ | |\n" +
72+
"| | / ___ | | || ||_ _||_ _|| || | |_ ___ `. | || | .' `. | || | |_ ||_ _| | || ||_ _||_ _|| |\n" +
73+
"| | | (__ \\_| | || | | | | | | || | | | `. \\ | || | / .--. \\ | || | | |_/ / | || | | | | | | |\n" +
74+
"| | '.___`-. | || | | ' ' | | || | | | | | | || | | | | | | || | | __'. | || | | ' ' | | |\n" +
75+
"| | |`\\____) | | || | \\ `--' / | || | _| |___.' / | || | \\ `--' / | || | _| | \\ \\_ | || | \\ `--' / | |\n" +
76+
"| | |_______.' | || | `.__.' | || | |________.' | || | `.____.' | || | |____||____| | || | `.__.' | |\n" +
77+
"| | | || | | || | | || | | || | | || | | |\n" +
78+
"| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |\n" +
79+
" '----------------' '----------------' '----------------' '----------------' '----------------' '----------------'");
80+
}
6481
}

src/main/java/de/borisskert/sudoku/console/Game.java

-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public void oneRound() {
5353
System.out.println("Solving...");
5454
puzzle.solve();
5555
}
56-
57-
printPuzzle();
5856
}
5957

6058
public boolean isSolved() {

0 commit comments

Comments
 (0)