Skip to content

Commit 53697d4

Browse files
committed
Merge remote-tracking branch 'origin/master' into HEAD
2 parents 221c3e1 + 4caa6b8 commit 53697d4

16 files changed

Lines changed: 93 additions & 61 deletions

File tree

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,4 @@ gradle-app.setting
2323
# Ignore Gradle build output directory
2424
build
2525

26-
archive.zip
27-
28-
temp
29-
30-
NumberGuessingGame
26+
archive.zip

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"github.copilot.enable": false
2+
"github.copilot.enable": false,
3+
"java.configuration.updateBuildConfiguration": "automatic"
34
}

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,18 @@ From the project root:
4949
gradle build
5050
```
5151

52-
Or from the app directory:
53-
```
54-
cd app
55-
gradle build
56-
```
57-
5852
### Running Tests
5953

6054
```
61-
cd app
6255
gradle test
6356
```
6457

6558
### Creating Release Archive
6659

67-
Run `./package.sh` from the project root. This will create `archive.zip` containing the application, run scripts, and README. The archive can be released to GitHub Releases.
60+
**On Windows:**
61+
Run `.\gradlew build` and `package.bat` from the project root.
62+
63+
**On Linux/Mac:**
64+
Run `./package.sh` from the project root.
65+
66+
This will create `archive.zip` containing the application, run scripts, and README. The archive can be released to GitHub Releases.

app/build.gradle

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ plugins {
44

55
//Spotless
66
id 'com.diffplug.spotless' version '8.0.0'
7-
/*
8-
// TeaVM
9-
id 'java'
10-
id 'war'
11-
id "org.teavm" version "0.12.3"
12-
*/
137
}
148

159
repositories {
@@ -20,10 +14,6 @@ repositories {
2014
dependencies {
2115
// This dependency is used by the application.
2216
implementation libs.guava
23-
/*
24-
// TeaVM
25-
implementation teavm.libs.jsoApis
26-
*/
2717
}
2818

2919
testing {
@@ -63,26 +53,6 @@ spotless {
6353
}
6454
}
6555

66-
/*
67-
teavm {
68-
all {
69-
mainClass = "io.github.project516.NumberGuessingGame.Main"
70-
}
71-
js {
72-
addedToWebApp = true
73-
74-
// this is also optional, default value is <project name>.js
75-
targetFileName = "NumberGuessingGame.js"
76-
}
77-
wasmGC {
78-
addedToWebApp = true
79-
80-
// this is also optional, default value is <project name>.wasm
81-
targetFileName = "NumberGuessingGame.wasm"
82-
}
83-
}
84-
*/
85-
8656
// Jar config
8757
jar {
8858
manifest {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.github.project516.NumberGuessingGame;
2+
3+
public class CheckGuess {
4+
void check(int guess) {
5+
if (guess < 1 || guess > 101) {
6+
throw new IllegalArgumentException("Invalid number!");
7+
}
8+
}
9+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.github.project516.NumberGuessingGame;
2+
3+
public class DebugInfo {
4+
5+
SystemInfo sysInfo = new SystemInfo();
6+
ReadVersionFile vFile = new ReadVersionFile();
7+
8+
void launchDebug() {
9+
System.out.println("===== DEBUG INFO =====\n\n");
10+
System.out.println("Java version: " + sysInfo.version());
11+
System.out.println("Vendor: " + sysInfo.vendor());
12+
System.out.println("JDK name: " + sysInfo.name());
13+
System.out.println("Number Guessing Game " + vFile.readVersion());
14+
System.out.println("\n\n======================\n\n");
15+
}
16+
17+
void gameCrash() {
18+
System.out.println("\n\n=====Program Crashed!=====\n\n");
19+
}
20+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.github.project516.NumberGuessingGame;
2+
3+
public class GameInfo {
4+
void about() {
5+
System.out.println("This is a Number Guessing Game!");
6+
System.out.println("Guess a number between 1 and 100!\n");
7+
}
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.github.project516.NumberGuessingGame;
2+
3+
public class GameLogic {
4+
// TODO port game logic from Main to GameLogic
5+
void start() {}
6+
}

app/src/main/java/io/github/project516/NumberGuessingGame/Main.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,22 @@ public static void main(String[] args) {
77
int numOfGuesses = 0;
88

99
ScannerHelper scan = new ScannerHelper();
10-
SystemInfo sysInfo = new SystemInfo();
1110
RandomNumber ranNumber = new RandomNumber();
11+
CheckGuess check = new CheckGuess();
12+
DebugInfo debugInfo = new DebugInfo();
13+
GameInfo gameInfo = new GameInfo();
1214

13-
try {
14-
15-
System.out.println("===== DEBUG INFO =====\n\n");
16-
System.out.println("Java version: " + sysInfo.version());
17-
System.out.println("Vendor: " + sysInfo.vendor());
18-
System.out.println("JDK name: " + sysInfo.name());
19-
System.out.println("\n\n======================\n\n");
15+
debugInfo.launchDebug();
2016

21-
int number = ranNumber.number();
22-
23-
System.out.println("This is a Number Guessing Game!");
24-
System.out.println("Guess a number between 1 and 100!\n");
17+
try {
18+
int number = ranNumber.number(100);
19+
gameInfo.about();
2520

2621
while (true) {
2722

2823
System.out.print("Guess a number: ");
2924
int guess = scan.userGuess();
25+
check.check(guess);
3026
if (guess > number) {
3127
System.out.println("You guessed to much!");
3228
} else if (guess < number) {
@@ -42,7 +38,7 @@ public static void main(String[] args) {
4238

4339
} catch (Exception e) {
4440

45-
System.out.println("\n\n=====Program Crashed!=====\n\n");
41+
debugInfo.gameCrash();
4642

4743
e.printStackTrace();
4844

0 commit comments

Comments
 (0)