Skip to content

Commit fc6e26d

Browse files
committed
0.0.6
2 parents 3052e55 + ef7dd51 commit fc6e26d

16 files changed

Lines changed: 162 additions & 7 deletions

File tree

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ A simple number guessing game where you try to guess a randomly generated number
99
For Debian/Ubuntu and derivatives (recommended for terminal usage):
1010

1111
1. Download the `.deb` package from the [latest release](https://github.com/Project516/NumberGuessingGame/releases)
12+
13+
You can use curl to do it from the command line:
14+
```bash
15+
curl -s -L -o numberguessingame.deb https://github.com/Project516/NumberGuessingGame/releases/download/0.0.x/numberguessinggame.deb
16+
```
17+
where `x` is the version you want.
1218
2. Install it:
1319
```bash
1420
sudo apt update # Update packages
15-
sudo apt install ./numberguessinggame.deb # From directory the deb package is in
16-
sudo apt install -f # Install dependencies if needed
21+
sudo apt install ./numberguessinggame.deb # From directory with the deb package
22+
sudo apt install -f # Install dependencies
1723
```
1824
3. Run from anywhere in your terminal:
1925
```bash
@@ -23,10 +29,13 @@ For Debian/Ubuntu and derivatives (recommended for terminal usage):
2329
To uninstall:
2430
```bash
2531
sudo apt remove numberguessinggame
32+
sudo apt autoremove -y # Remove dependencies
2633
```
2734

2835
### Manual Installation
2936

37+
Download the `zip` archive from the [latest release](https://github.com/project516/numberguessinggame/releases)
38+
3039
#### Requirements
3140

3241
- Java 8 or higher (may require Java 17+ in future versions)

app/src/main/java/io/github/project516/NumberGuessingGame/CheckGuess.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+
* Validates user guesses in the Number Guessing Game. This class ensures that user input falls
5+
* within the acceptable range.
6+
*/
37
public class CheckGuess {
8+
/**
9+
* Validates that a guess is within the acceptable range (1-100).
10+
*
11+
* @param guess the user's guess to validate
12+
* @throws IllegalArgumentException if the guess is less than 1 or greater than 101
13+
*/
414
void check(int guess) {
515
if (guess < 1 || guess > 101) {
616
throw new IllegalArgumentException("Invalid number!");

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

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

3+
/**
4+
* Provides debugging information for the Number Guessing Game. This class displays system
5+
* information and version details, and handles game crash notifications.
6+
*/
37
public class DebugInfo {
48

9+
/** System information provider. */
510
SystemInfo sysInfo = new SystemInfo();
11+
12+
/** Version file reader. */
613
ReadVersionFile vFile = new ReadVersionFile();
714

15+
/**
16+
* Displays debug information including Java version, vendor, JDK name, and game version to the
17+
* console.
18+
*/
819
void launchDebug() {
920
System.out.println("\n===== DEBUG INFO =====\n\n");
1021
System.out.println("Java version: " + sysInfo.version());
@@ -14,6 +25,10 @@ void launchDebug() {
1425
System.out.println("\n\n======================\n\n");
1526
}
1627

28+
/**
29+
* Displays a message when the game crashes. Called when an unexpected exception occurs during
30+
* game execution.
31+
*/
1732
void gameCrash() {
1833
System.out.println("\n\n===Program Crashed!===\n\n");
1934
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55

66
// TODO
77

8+
/**
9+
* Graphical User Interface for the Number Guessing Game. This class creates and manages the game's
10+
* window and UI components. Currently under development.
11+
*/
812
public class GUI {
13+
/**
14+
* Creates and displays the main game window. Sets up a JFrame with a centered label showing the
15+
* game title.
16+
*/
917
void createWindow() {
1018
JFrame jframe = new JFrame("Number Guessing Game");
1119
JLabel jlabel = new JLabel("Number Guessing Game", SwingConstants.CENTER);
@@ -19,6 +27,11 @@ void createWindow() {
1927
jframe.setVisible(true); // Set visible
2028
}
2129

30+
/**
31+
* Test method for the GUI. Creates a GUI instance and displays the window for testing purposes.
32+
*
33+
* @param args command line arguments (not used)
34+
*/
2235
public static void main(String[] args) { // Test GUI
2336
GUI GUI = new GUI();
2437
GUI.createWindow();

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

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

3+
/**
4+
* Provides information about the Number Guessing Game application. This class contains methods to
5+
* display game information, author details, project URL, and online Javadoc location.
6+
*/
37
public class GameInfo {
8+
/**
9+
* Displays information about the game to the console. Prints the game title and instructions
10+
* for the player.
11+
*/
412
void about() {
513
System.out.println("This is a Number Guessing Game!");
614
System.out.println("Guess a number between 1 and 100!\n");
715
}
816

17+
/**
18+
* Returns the author of the Number Guessing Game.
19+
*
20+
* @return the author's username
21+
*/
922
String author() {
1023
return "project516";
1124
}
1225

26+
/**
27+
* Returns the project's GitHub repository URL.
28+
*
29+
* @return the GitHub project URL
30+
*/
1331
String projectURL() {
1432
return "https://github.com/project516/numberguessinggame";
1533
}
1634

35+
/**
36+
* Returns the URL for the online Javadoc documentation.
37+
*
38+
* @return the online Javadoc URL
39+
*/
1740
String onlineJavadoc() {
1841
return "https://project516.github.io/NumberGuessingGame";
1942
}

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

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

3+
/**
4+
* Contains the main game logic for the Number Guessing Game. This class manages the game loop, user
5+
* input, and guess validation.
6+
*/
37
public class GameLogic {
48
// TODO port game logic from Main to GameLogic
9+
/**
10+
* Runs the main game loop. Generates a random number and prompts the user to guess it. Provides
11+
* feedback on each guess and tracks the number of attempts.
12+
*/
513
void game() {
614

715
RandomNumber ranNumber = new RandomNumber();

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
package io.github.project516.NumberGuessingGame;
22

3+
/**
4+
* Main entry point for the Number Guessing Game application. This class initializes the game
5+
* components and starts the game.
6+
*/
37
public class Main {
48

9+
/**
10+
* The main method that starts the Number Guessing Game. Initializes all necessary components,
11+
* displays debug information, and runs the game logic with proper error handling.
12+
*
13+
* @param args command line arguments (not currently used)
14+
*/
515
public static void main(String[] args) {
616

717
ScannerHelper scan = new ScannerHelper();
@@ -19,7 +29,6 @@ public static void main(String[] args) {
1929
} catch (Exception e) {
2030

2131
debugInfo.gameCrash();
22-
2332
e.printStackTrace();
2433

2534
} finally {

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22

33
import java.util.*;
44

5+
/**
6+
* Generates random numbers for the Number Guessing Game. This class uses Java's Random class to
7+
* generate random integers within a specified range.
8+
*/
59
public class RandomNumber {
610

11+
/** Random number generator instance. */
712
Random random = new Random();
813

14+
/**
15+
* Generates a random integer between 0 and the specified maximum value (inclusive).
16+
*
17+
* @param max the maximum value for the random number
18+
* @return a random integer between 0 and max (inclusive)
19+
*/
920
int number(int max) {
1021

1122
return random.nextInt(max + 1);
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
package io.github.project516.NumberGuessingGame;
22

3+
/**
4+
* Reads version information for the Number Guessing Game. Currently returns a placeholder version
5+
* string.
6+
*/
37
public class ReadVersionFile {
48
// TODO - make this read the file in the resources directory
9+
/**
10+
* Retrieves the current version of the game. Currently returns "rolling" as a placeholder.
11+
*
12+
* @return the version string
13+
*/
514
public String readVersion() {
6-
return "0.0.5";
15+
return "0.0.6";
716
}
817
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,37 @@
22

33
import java.util.Scanner;
44

5+
/**
6+
* Helper class for managing user input via Scanner. This class provides methods to read user
7+
* guesses, usernames, and properly close the Scanner resource.
8+
*/
59
public class ScannerHelper {
610

11+
/** Scanner instance for reading user input from System.in. */
712
public Scanner scan = new Scanner(System.in);
813

14+
/**
15+
* Reads the user's guess as an integer from standard input.
16+
*
17+
* @return the user's guess as an integer
18+
*/
919
int userGuess() {
1020
return scan.nextInt();
1121
}
1222

23+
/**
24+
* Reads the user's name as a string from standard input.
25+
*
26+
* @return the user's name as a string
27+
*/
1328
String userName() {
1429
return scan.nextLine();
1530
}
1631

32+
/**
33+
* Closes the Scanner to release system resources. Should be called when the Scanner is no
34+
* longer needed.
35+
*/
1736
void close() {
1837
scan.close();
1938
}

0 commit comments

Comments
 (0)