diff --git a/README.md b/README.md
index eb50ee9..e5b11cd 100644
--- a/README.md
+++ b/README.md
@@ -62,7 +62,7 @@ Download the `archive.zip` from the [latest release](https://github.com/project5
#### Requirements
-- Java 11 or higher
+- Java 17 or higher
#### How to Run
diff --git a/app/build.gradle b/app/build.gradle
index a04c555..d04c022 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -27,7 +27,7 @@ testing {
// Configure the built-in test suite
test {
// Use JUnit Jupiter test framework
- useJUnitJupiter('5.14.0')
+ useJUnitJupiter('6.0.0')
}
}
}
@@ -44,7 +44,7 @@ tasks.withType(JavaCompile) {
// Changed from 8 to 11 to support TeaVM for web deployment.
// TeaVM 0.10.2+ requires Java 11 as minimum target.
// This change affects the minimum JRE required to run the JAR.
- options.release.set(11)
+ options.release.set(17)
}
application {
diff --git a/app/src/main/java/io/github/project516/NumberGuessingGame/CheckGuess.java b/app/src/main/java/io/github/project516/NumberGuessingGame/CheckGuess.java
index 2cbb786..5eb0af9 100644
--- a/app/src/main/java/io/github/project516/NumberGuessingGame/CheckGuess.java
+++ b/app/src/main/java/io/github/project516/NumberGuessingGame/CheckGuess.java
@@ -17,6 +17,12 @@ void check(int guess) {
}
}
+ /**
+ * Validates the user's response to the "play again" prompt.
+ *
+ * @param input the user's input (0 to quit, 1 to continue)
+ * @throws IllegalArgumentException if the input is not 0 or 1
+ */
void quit(int input) {
// 0 is quit
// 1 is continue
diff --git a/app/src/main/java/io/github/project516/NumberGuessingGame/NumberGuessingGame.java b/app/src/main/java/io/github/project516/NumberGuessingGame/NumberGuessingGame.java
index e5b5e47..c73eb25 100644
--- a/app/src/main/java/io/github/project516/NumberGuessingGame/NumberGuessingGame.java
+++ b/app/src/main/java/io/github/project516/NumberGuessingGame/NumberGuessingGame.java
@@ -1,6 +1,16 @@
package io.github.project516.NumberGuessingGame;
+/**
+ * Console-based Number Guessing Game implementation. This class manages the console version of the
+ * game, handling the game loop, user interaction, and error recovery. It prompts the user to guess
+ * numbers and allows replaying the game.
+ */
public class NumberGuessingGame {
+ /**
+ * Runs the console version of the Number Guessing Game. Initializes all game components,
+ * displays debug information, and manages the game loop. The user can play multiple rounds
+ * until they choose to quit.
+ */
void run() {
ScannerHelper scan = new ScannerHelper();
DebugInfo debugInfo = new DebugInfo();
diff --git a/app/src/main/java/io/github/project516/NumberGuessingGame/ScannerHelper.java b/app/src/main/java/io/github/project516/NumberGuessingGame/ScannerHelper.java
index b3c2b68..c5a21b3 100644
--- a/app/src/main/java/io/github/project516/NumberGuessingGame/ScannerHelper.java
+++ b/app/src/main/java/io/github/project516/NumberGuessingGame/ScannerHelper.java
@@ -29,6 +29,10 @@ String userName() {
return scan.nextLine();
}
+ /**
+ * Consumes the next token from the input stream. Used primarily for clearing invalid input
+ * after an exception occurs.
+ */
void next() {
scan.next();
}
diff --git a/cheerpj.sh b/cheerpj.sh
deleted file mode 100755
index aaadc4b..0000000
--- a/cheerpj.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-./gradlew build
-rm -f cheerpj/app.jar
-cp app/build/libs/app.jar cheerpj
-mkdir -p app/build/docs/javadoc/cheerpj
-cp -f cheerpj/* app/build/docs/javadoc/cheerpj/
diff --git a/cheerpj/app.jar b/cheerpj/app.jar
deleted file mode 100644
index 2e54ed4..0000000
Binary files a/cheerpj/app.jar and /dev/null differ
diff --git a/cheerpj/index.html b/cheerpj/index.html
deleted file mode 100644
index 18a650f..0000000
--- a/cheerpj/index.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
- CheerpJ test
-
-
-
-
-
-
\ No newline at end of file
diff --git a/package-deb.sh b/package-deb.sh
index 6ed668e..3c1ff9c 100755
--- a/package-deb.sh
+++ b/package-deb.sh
@@ -1,36 +1,43 @@
#!/bin/sh
# Script to create a Debian package (.deb) for Number Guessing Game
+# This package can be installed on Debian-based Linux distributions (Ubuntu, Mint, etc.)
+# Usage: ./package-deb.sh
+# Output: numberguessinggame.deb
+# Exit immediately if any command fails
set -e
echo "Building Number Guessing Game Debian package..."
-# Clean up previous builds
+# Clean up any previous build artifacts
+echo "Cleaning up previous builds..."
rm -rf debian-package/usr/share/games/numberguessinggame/*
rm -f numberguessinggame.deb
-# Build the application
+# Build the application using Gradle
echo "Building application..."
gradle build
-# Copy the jar file
+# Copy the compiled JAR file to the package directory
echo "Copying files to package directory..."
cp app/build/libs/app.jar debian-package/usr/share/games/numberguessinggame/game.jar
-# Copy documentation
+# Copy documentation files
cp README.md debian-package/usr/share/games/numberguessinggame/README.md
cp LICENSE debian-package/usr/share/games/numberguessinggame/LICENSE
-# Set permissions
+# Set correct permissions for Debian package
+echo "Setting file permissions..."
chmod 755 debian-package/DEBIAN
chmod 755 debian-package/DEBIAN/postinst
chmod 755 debian-package/usr/games/numberguessinggame
-# Build the .deb package
+# Build the .deb package using dpkg-deb
echo "Building .deb package..."
dpkg-deb --build debian-package numberguessinggame.deb
+# Display success message with installation instructions
echo ""
echo "✓ Debian package created: numberguessinggame.deb"
echo ""
diff --git a/package-linux.sh b/package-linux.sh
index a4b4b14..e5a848c 100755
--- a/package-linux.sh
+++ b/package-linux.sh
@@ -1,6 +1,9 @@
#!/bin/sh
# Script to create a Linux package with bundled JRE for Number Guessing Game
+# This creates a self-contained package that doesn't require Java to be installed
+# Output: NumberGuessingGame-linux.tar.gz
+# Exit immediately if any command fails
set -e
echo "Building Number Guessing Game for Linux with bundled JRE..."
@@ -10,21 +13,21 @@ PACKAGE_NAME="NumberGuessingGame-linux"
JRE_DIR="jre-linux"
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"
-# Clean up previous builds
+# Clean up any previous builds
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
rm -f ${PACKAGE_NAME}.tar.gz
-# Build the application
+# Build the application using Gradle
echo "Building application..."
./gradlew build
-# Download JRE for Linux
+# Download JRE for Linux from Eclipse Adoptium
echo "Downloading JRE for Linux..."
mkdir -p ${JRE_DIR}
curl -L "${ADOPTIUM_BASE_URL}/linux/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-linux.tar.gz
-# Extract JRE
+# Extract the downloaded JRE
echo "Extracting JRE..."
cd ${JRE_DIR}
tar -xzf jre-linux.tar.gz
@@ -38,11 +41,11 @@ cp app/build/libs/app.jar ${PACKAGE_NAME}/game.jar
cp README.md ${PACKAGE_NAME}/README.txt
cp LICENSE ${PACKAGE_NAME}/LICENSE
-# Copy JRE into package
+# Copy the JRE into the package
echo "Copying JRE into package..."
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre
-# Create run.sh that uses bundled JRE
+# Create a shell script that uses the bundled JRE
cat > ${PACKAGE_NAME}/run.sh << 'EOF'
#!/bin/sh
@@ -52,13 +55,14 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"${SCRIPT_DIR}/jre/bin/java" -jar "${SCRIPT_DIR}/game.jar"
EOF
+# Make the run script executable
chmod +x ${PACKAGE_NAME}/run.sh
-# Create the tar.gz archive
+# Create the final tar.gz archive
echo "Creating tar.gz archive..."
tar -czf ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME}/
-# Clean up
+# Clean up temporary directories
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
diff --git a/package-macos.sh b/package-macos.sh
index 3a42fb2..ef1718d 100755
--- a/package-macos.sh
+++ b/package-macos.sh
@@ -1,6 +1,9 @@
#!/bin/sh
# Script to create a macOS package with bundled JRE for Number Guessing Game
+# This creates a self-contained package that doesn't require Java to be installed
+# Output: NumberGuessingGame-macos.zip
+# Exit immediately if any command fails
set -e
echo "Building Number Guessing Game for macOS with bundled JRE..."
@@ -10,21 +13,21 @@ PACKAGE_NAME="NumberGuessingGame-macos"
JRE_DIR="jre-macos"
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"
-# Clean up previous builds
+# Clean up any previous builds
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
rm -f ${PACKAGE_NAME}.zip
-# Build the application
+# Build the application using Gradle
echo "Building application..."
./gradlew build
-# Download JRE for macOS
+# Download JRE for macOS from Eclipse Adoptium
echo "Downloading JRE for macOS..."
mkdir -p ${JRE_DIR}
curl -L "${ADOPTIUM_BASE_URL}/mac/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-macos.tar.gz
-# Extract JRE
+# Extract the downloaded JRE
echo "Extracting JRE..."
cd ${JRE_DIR}
tar -xzf jre-macos.tar.gz
@@ -38,11 +41,11 @@ cp app/build/libs/app.jar ${PACKAGE_NAME}/game.jar
cp README.md ${PACKAGE_NAME}/README.txt
cp LICENSE ${PACKAGE_NAME}/LICENSE
-# Copy JRE into package
+# Copy the JRE into the package
echo "Copying JRE into package..."
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre
-# Create run.sh that uses bundled JRE
+# Create a shell script that uses the bundled JRE (macOS JRE structure: Contents/Home)
cat > ${PACKAGE_NAME}/run.sh << 'EOF'
#!/bin/sh
@@ -52,13 +55,14 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"${SCRIPT_DIR}/jre/Contents/Home/bin/java" -jar "${SCRIPT_DIR}/game.jar"
EOF
+# Make the run script executable
chmod +x ${PACKAGE_NAME}/run.sh
-# Create the zip archive
+# Create the final zip archive
echo "Creating zip archive..."
zip -r ${PACKAGE_NAME}.zip ${PACKAGE_NAME}/
-# Clean up
+# Clean up temporary directories
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
diff --git a/package-win.sh b/package-win.sh
index a2a26d5..289ce8c 100755
--- a/package-win.sh
+++ b/package-win.sh
@@ -1,6 +1,9 @@
#!/bin/sh
# Script to create a Windows package with bundled JRE for Number Guessing Game
+# This creates a self-contained package that doesn't require Java to be installed
+# Output: NumberGuessingGame-windows.zip
+# Exit immediately if any command fails
set -e
echo "Building Number Guessing Game for Windows with bundled JRE..."
@@ -10,21 +13,21 @@ PACKAGE_NAME="NumberGuessingGame-windows"
JRE_DIR="jre-windows"
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"
-# Clean up previous builds
+# Clean up any previous builds
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
rm -f ${PACKAGE_NAME}.zip
-# Build the application
+# Build the application using Gradle
echo "Building application..."
./gradlew build
-# Download JRE for Windows
+# Download JRE for Windows from Eclipse Adoptium
echo "Downloading JRE for Windows..."
mkdir -p ${JRE_DIR}
curl -L "${ADOPTIUM_BASE_URL}/windows/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-windows.zip
-# Extract JRE
+# Extract the downloaded JRE
echo "Extracting JRE..."
cd ${JRE_DIR}
unzip -q jre-windows.zip
@@ -38,11 +41,11 @@ cp app/build/libs/app.jar ${PACKAGE_NAME}/game.jar
cp README.md ${PACKAGE_NAME}/README.txt
cp LICENSE ${PACKAGE_NAME}/LICENSE
-# Copy JRE into package
+# Copy the JRE into the package
echo "Copying JRE into package..."
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre
-# Create run.bat that uses bundled JRE
+# Create a Windows batch file that uses the bundled JRE
cat > ${PACKAGE_NAME}/run.bat << 'EOF'
@echo off
@@ -51,11 +54,11 @@ jre\bin\java.exe -jar game.jar
@pause
EOF
-# Create the zip archive
+# Create the final zip archive
echo "Creating zip archive..."
zip -r ${PACKAGE_NAME}.zip ${PACKAGE_NAME}/
-# Clean up
+# Clean up temporary directories
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
diff --git a/package-zip.bat b/package-zip.bat
index 96d73af..f65a778 100644
--- a/package-zip.bat
+++ b/package-zip.bat
@@ -1,15 +1,26 @@
@echo off
+REM Creates a distributable ZIP archive of the game (Windows)
+REM This archive requires Java to be installed on the user's system
+REM Clean up any previous builds
rmdir /s /q NumberGuessingGame 2>nul
rmdir /s /q temp 2>nul
del /f archive.zip 2>nul
+
+REM Create distribution directory structure
mkdir NumberGuessingGame
+
+REM Copy the game JAR and necessary files
copy app\build\libs\app.jar NumberGuessingGame\game.jar
copy scripts\run.bat NumberGuessingGame\run.bat
copy scripts\run.sh NumberGuessingGame\run.sh
copy README.md NumberGuessingGame\README.txt
copy LICENSE NumberGuessingGame\LICENSE
+
+REM Create the ZIP archive using PowerShell
powershell -command "Compress-Archive -Path NumberGuessingGame -DestinationPath archive.zip -Force"
+
+REM Clean up temporary directory
rmdir /s /q NumberGuessingGame
@pause
\ No newline at end of file
diff --git a/package-zip.sh b/package-zip.sh
index 70f93a0..8b6485d 100755
--- a/package-zip.sh
+++ b/package-zip.sh
@@ -1,16 +1,29 @@
#!/bin/sh
+# Creates a distributable ZIP archive of the game
+# This archive requires Java to be installed on the user's system
+# Clean up any previous builds
rm -rf NumberGuessingGame
rm -rf temp
rm -f archive.zip
+
+# Build the application
cd app
gradle build
cd ..
+
+# Create distribution directory structure
mkdir NumberGuessingGame
+
+# Copy the game JAR and necessary files
cp -r app/build/libs/app.jar NumberGuessingGame/game.jar
cp -r scripts/run.bat NumberGuessingGame/run.bat
cp -r scripts/run.sh NumberGuessingGame/run.sh
cp -r README.md NumberGuessingGame/README.txt
cp -r LICENSE NumberGuessingGame/LICENSE
+
+# Create the ZIP archive
zip -r archive.zip NumberGuessingGame/
+
+# Clean up temporary directory
rm -rf NumberGuessingGame
diff --git a/scripts/run.bat b/scripts/run.bat
index 6b55fb4..87bc8ef 100644
--- a/scripts/run.bat
+++ b/scripts/run.bat
@@ -1,4 +1,7 @@
@echo off
+REM Run script for Number Guessing Game (Windows)
+REM This script starts the GUI version of the game
+REM For console mode, add --console flag: run.bat --console
java -jar game.jar
diff --git a/scripts/run.sh b/scripts/run.sh
index 705c891..eac680f 100644
--- a/scripts/run.sh
+++ b/scripts/run.sh
@@ -1,3 +1,6 @@
#!/bin/sh
+# Run script for Number Guessing Game (Linux/Mac)
+# This script starts the GUI version of the game
+# For console mode, add --console flag: ./run.sh --console
java -jar game.jar
diff --git a/teavm.sh b/teavm.sh
index 05a3e3d..7aea388 100755
--- a/teavm.sh
+++ b/teavm.sh
@@ -1,16 +1,21 @@
#!/bin/sh
# Script to build TeaVM JavaScript output for GitHub Pages deployment
-# This replaces the cheerpj.sh script
+# TeaVM compiles Java bytecode to JavaScript for running in web browsers
+# This script replaces the old cheerpj.sh approach
+# Output: JavaScript files in app/build/docs/javadoc/teavm/
echo "Building project..."
./gradlew build
echo "Compiling Java to JavaScript with TeaVM..."
-# Disable configuration cache due to TeaVM plugin compatibility
+# Note: Configuration cache is disabled due to TeaVM plugin compatibility
./gradlew teavmc --no-configuration-cache
echo "Copying TeaVM output to javadoc directory..."
+# Create output directory if it doesn't exist
mkdir -p app/build/docs/javadoc/teavm
+
+# Copy generated JavaScript and HTML files
cp -f app/build/teavm/classes.js app/build/docs/javadoc/teavm/
cp -f teavm/index.html app/build/docs/javadoc/teavm/
diff --git a/test-gui.bat b/test-gui.bat
index 82c3ce9..01a3e20 100644
--- a/test-gui.bat
+++ b/test-gui.bat
@@ -1,5 +1,9 @@
@echo off
+REM Quick test script for GUI mode (Windows)
+REM This script runs the graphical version of the game
+REM Note: Run gradlew.bat build first to compile the project
+REM Run the game in GUI mode (default - opens a window)
java -jar app/build/libs/app.jar
@pause
diff --git a/test-gui.sh b/test-gui.sh
index d51c663..a163e66 100644
--- a/test-gui.sh
+++ b/test-gui.sh
@@ -1,4 +1,9 @@
#!/bin/sh
+# Quick test script for GUI mode
+# This script builds the project and runs the graphical version of the game
+# Build the project using Gradle
./gradlew build
+
+# Run the game in GUI mode (default - opens a window)
java -jar app/build/libs/app.jar
diff --git a/test.bat b/test.bat
index 2ea269b..bb0aa1d 100644
--- a/test.bat
+++ b/test.bat
@@ -1,5 +1,9 @@
@echo off
+REM Quick test script for console mode (Windows)
+REM This script runs the console version of the game
+REM Note: Run gradlew.bat build first to compile the project
+REM Run the game in console mode (text-based interface)
java -jar app/build/libs/app.jar --console
@pause
diff --git a/test.sh b/test.sh
index 26b9281..67503c4 100755
--- a/test.sh
+++ b/test.sh
@@ -1,4 +1,9 @@
#!/bin/sh
+# Quick test script for console mode
+# This script builds the project and runs the console version of the game
+# Build the project using Gradle
./gradlew build
+
+# Run the game in console mode (text-based interface)
java -jar app/build/libs/app.jar --console