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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
public class CheckGuess {
/**
* Validates that a guess is within the acceptable range (1-100).
* Validates that a guess is within the acceptable range (1-101).
*
* @param guess the user's guess to validate
* @throws IllegalArgumentException if the guess is less than 1 or greater than 101
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public int compareTo(HighScore other) {
return Integer.compare(this.numberOfGuesses, other.numberOfGuesses);
}

/**
* Returns a string representation of this high score in the format "username: X guess(es)".
*
* @return a formatted string containing the username and number of guesses
*/
@Override
public String toString() {
return username + ": " + numberOfGuesses + " guess" + (numberOfGuesses == 1 ? "" : "es");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class RandomNumber {
Random random = new Random();

/**
* Generates a random integer between 0 and the specified maximum value (inclusive).
* Generates a random integer between 0 (inclusive) and the specified maximum value (inclusive).
*
* @param max the maximum value for the random number
* @return a random integer between 0 and max (inclusive)
* @param max the maximum value for the random number (inclusive)
* @return a random integer in the range [0, max]
*/
int number(int max) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
import java.io.InputStream;
import java.io.InputStreamReader;

/**
* Reads version information for the Number Guessing Game. Currently returns a placeholder version
* string.
*/
/** Reads version information for the Number Guessing Game from the version.txt resource file. */
public class ReadVersionFile {
/**
* Retrieves the current version of the game by reading from the version.txt resource file.
*
* @return the version string
*/
public String readVersion() {
String content = "1.0.0"; // Placeholder version
String content = "1.0.0"; // Default fallback version
try (InputStream inputStream =
getClass().getClassLoader().getResourceAsStream("version.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
Expand Down
Loading