Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
7 changes: 0 additions & 7 deletions cheerpj.sh

This file was deleted.

Binary file removed cheerpj/app.jar
Binary file not shown.
17 changes: 0 additions & 17 deletions cheerpj/index.html

This file was deleted.

19 changes: 13 additions & 6 deletions package-deb.sh
Original file line number Diff line number Diff line change
@@ -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 ""
Expand Down
20 changes: 12 additions & 8 deletions package-linux.sh
Original file line number Diff line number Diff line change
@@ -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..."
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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}

Expand Down
20 changes: 12 additions & 8 deletions package-macos.sh
Original file line number Diff line number Diff line change
@@ -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..."
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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}

Expand Down
19 changes: 11 additions & 8 deletions package-win.sh
Original file line number Diff line number Diff line change
@@ -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..."
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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}

Expand Down
11 changes: 11 additions & 0 deletions package-zip.bat
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading