Skip to content

Commit 41a9cca

Browse files
authored
Merge pull request #73 from Project516/master
Update
2 parents 69a5ffc + c300a85 commit 41a9cca

File tree

21 files changed

+126
-59
lines changed

21 files changed

+126
-59
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Download the `archive.zip` from the [latest release](https://github.com/project5
6262

6363
#### Requirements
6464

65-
- Java 11 or higher
65+
- Java 17 or higher
6666

6767
#### How to Run
6868

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ testing {
2727
// Configure the built-in test suite
2828
test {
2929
// Use JUnit Jupiter test framework
30-
useJUnitJupiter('5.14.0')
30+
useJUnitJupiter('6.0.0')
3131
}
3232
}
3333
}
@@ -44,7 +44,7 @@ tasks.withType(JavaCompile) {
4444
// Changed from 8 to 11 to support TeaVM for web deployment.
4545
// TeaVM 0.10.2+ requires Java 11 as minimum target.
4646
// This change affects the minimum JRE required to run the JAR.
47-
options.release.set(11)
47+
options.release.set(17)
4848
}
4949

5050
application {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ void check(int guess) {
1717
}
1818
}
1919

20+
/**
21+
* Validates the user's response to the "play again" prompt.
22+
*
23+
* @param input the user's input (0 to quit, 1 to continue)
24+
* @throws IllegalArgumentException if the input is not 0 or 1
25+
*/
2026
void quit(int input) {
2127
// 0 is quit
2228
// 1 is continue

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
package io.github.project516.NumberGuessingGame;
22

3+
/**
4+
* Console-based Number Guessing Game implementation. This class manages the console version of the
5+
* game, handling the game loop, user interaction, and error recovery. It prompts the user to guess
6+
* numbers and allows replaying the game.
7+
*/
38
public class NumberGuessingGame {
9+
/**
10+
* Runs the console version of the Number Guessing Game. Initializes all game components,
11+
* displays debug information, and manages the game loop. The user can play multiple rounds
12+
* until they choose to quit.
13+
*/
414
void run() {
515
ScannerHelper scan = new ScannerHelper();
616
DebugInfo debugInfo = new DebugInfo();

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ String userName() {
2929
return scan.nextLine();
3030
}
3131

32+
/**
33+
* Consumes the next token from the input stream. Used primarily for clearing invalid input
34+
* after an exception occurs.
35+
*/
3236
void next() {
3337
scan.next();
3438
}

cheerpj.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

cheerpj/app.jar

-14.6 KB
Binary file not shown.

cheerpj/index.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

package-deb.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
11
#!/bin/sh
22
# Script to create a Debian package (.deb) for Number Guessing Game
3+
# This package can be installed on Debian-based Linux distributions (Ubuntu, Mint, etc.)
4+
# Usage: ./package-deb.sh
5+
# Output: numberguessinggame.deb
36

7+
# Exit immediately if any command fails
48
set -e
59

610
echo "Building Number Guessing Game Debian package..."
711

8-
# Clean up previous builds
12+
# Clean up any previous build artifacts
13+
echo "Cleaning up previous builds..."
914
rm -rf debian-package/usr/share/games/numberguessinggame/*
1015
rm -f numberguessinggame.deb
1116

12-
# Build the application
17+
# Build the application using Gradle
1318
echo "Building application..."
1419

1520
gradle build
1621

17-
# Copy the jar file
22+
# Copy the compiled JAR file to the package directory
1823
echo "Copying files to package directory..."
1924
cp app/build/libs/app.jar debian-package/usr/share/games/numberguessinggame/game.jar
2025

21-
# Copy documentation
26+
# Copy documentation files
2227
cp README.md debian-package/usr/share/games/numberguessinggame/README.md
2328
cp LICENSE debian-package/usr/share/games/numberguessinggame/LICENSE
2429

25-
# Set permissions
30+
# Set correct permissions for Debian package
31+
echo "Setting file permissions..."
2632
chmod 755 debian-package/DEBIAN
2733
chmod 755 debian-package/DEBIAN/postinst
2834
chmod 755 debian-package/usr/games/numberguessinggame
2935

30-
# Build the .deb package
36+
# Build the .deb package using dpkg-deb
3137
echo "Building .deb package..."
3238
dpkg-deb --build debian-package numberguessinggame.deb
3339

40+
# Display success message with installation instructions
3441
echo ""
3542
echo "✓ Debian package created: numberguessinggame.deb"
3643
echo ""

package-linux.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/sh
22
# Script to create a Linux package with bundled JRE for Number Guessing Game
3+
# This creates a self-contained package that doesn't require Java to be installed
4+
# Output: NumberGuessingGame-linux.tar.gz
35

6+
# Exit immediately if any command fails
47
set -e
58

69
echo "Building Number Guessing Game for Linux with bundled JRE..."
@@ -10,21 +13,21 @@ PACKAGE_NAME="NumberGuessingGame-linux"
1013
JRE_DIR="jre-linux"
1114
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"
1215

13-
# Clean up previous builds
16+
# Clean up any previous builds
1417
rm -rf ${PACKAGE_NAME}
1518
rm -rf ${JRE_DIR}
1619
rm -f ${PACKAGE_NAME}.tar.gz
1720

18-
# Build the application
21+
# Build the application using Gradle
1922
echo "Building application..."
2023
./gradlew build
2124

22-
# Download JRE for Linux
25+
# Download JRE for Linux from Eclipse Adoptium
2326
echo "Downloading JRE for Linux..."
2427
mkdir -p ${JRE_DIR}
2528
curl -L "${ADOPTIUM_BASE_URL}/linux/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-linux.tar.gz
2629

27-
# Extract JRE
30+
# Extract the downloaded JRE
2831
echo "Extracting JRE..."
2932
cd ${JRE_DIR}
3033
tar -xzf jre-linux.tar.gz
@@ -38,11 +41,11 @@ cp app/build/libs/app.jar ${PACKAGE_NAME}/game.jar
3841
cp README.md ${PACKAGE_NAME}/README.txt
3942
cp LICENSE ${PACKAGE_NAME}/LICENSE
4043

41-
# Copy JRE into package
44+
# Copy the JRE into the package
4245
echo "Copying JRE into package..."
4346
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre
4447

45-
# Create run.sh that uses bundled JRE
48+
# Create a shell script that uses the bundled JRE
4649
cat > ${PACKAGE_NAME}/run.sh << 'EOF'
4750
#!/bin/sh
4851
@@ -52,13 +55,14 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5255
"${SCRIPT_DIR}/jre/bin/java" -jar "${SCRIPT_DIR}/game.jar"
5356
EOF
5457

58+
# Make the run script executable
5559
chmod +x ${PACKAGE_NAME}/run.sh
5660

57-
# Create the tar.gz archive
61+
# Create the final tar.gz archive
5862
echo "Creating tar.gz archive..."
5963
tar -czf ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME}/
6064

61-
# Clean up
65+
# Clean up temporary directories
6266
rm -rf ${PACKAGE_NAME}
6367
rm -rf ${JRE_DIR}
6468

0 commit comments

Comments
 (0)