update HockeyPlayer javadocs

This commit is contained in:
Cool Guy
2026-05-05 20:28:30 +00:00
parent 4088203644
commit 83269126bb

View File

@@ -1,8 +1,8 @@
/**
* HockeyPlayer.java
*
* Represents a hockey player and tracks their performance statistics
* such as goals, assists, and win/loss records.
* <p>Represents a hockey player and tracks their performance statistics such as goals, assists, and
* win/loss records.
*
* @author Cody Trainer
*/
@@ -12,6 +12,7 @@ public class HockeyPlayer {
/**
* Constructs a new HockeyPlayer with full statistics.
*
* @param n The player's name.
* @param g Number of goals scored.
* @param a Number of assists made.
@@ -28,6 +29,7 @@ public class HockeyPlayer {
/**
* Constructs a new HockeyPlayer with a name and zeroed statistics.
*
* @param name The player's name.
*/
public HockeyPlayer(String name) {
@@ -36,14 +38,16 @@ public class HockeyPlayer {
/**
* getName gets the player's name
*
* @return The player's name.
*/
*/
public String getName() {
return name;
}
/**
* getGoals gets the player's total goals scored
*
* @return Total goals scored.
*/
public int getGoals() {
@@ -52,6 +56,7 @@ public class HockeyPlayer {
/**
* getAssists gets the player's total assists recorded
*
* @return Total assists recorded.
*/
public int getAssists() {
@@ -60,19 +65,25 @@ public class HockeyPlayer {
/**
* getGamesWon gets the player's total games won
*
* @return Total games won.
*/
public int getGamesWon() {
return gamesWon;
}
/** @return Total games lost. */
/**
* getGamesLost gets the player's total games lost
*
* @return Total games lost.
*/
public int getGamesLost() {
return gamesLost;
}
/**
* Calculates total points (goals + assists).
*
* @return The sum of goals and assists.
*/
public int getPoints() {
@@ -81,6 +92,7 @@ public class HockeyPlayer {
/**
* Calculates total games played.
*
* @return The sum of games won and games lost.
*/
public int getGamesPlayed() {
@@ -89,6 +101,7 @@ public class HockeyPlayer {
/**
* Calculates the average points earned per game.
*
* @return Points divided by games played as a double.
*/
public double getPointsPerGame() {
@@ -97,9 +110,10 @@ public class HockeyPlayer {
/**
* Returns a formatted string containing the player's full statistics.
*
* @return A multi-line summary of the player.
*/
public String toString() {
public String toString() {
String s =
String.format(
"Name: %s%nGoals: %d\tAssists: %d\tPoints: %d\tPoints Per Game: %f%nGames Won: %d"
@@ -117,6 +131,7 @@ public class HockeyPlayer {
/**
* Returns the raw data of the player in a single line format.
*
* @return A string formatted as "name goals assists wins losses".
*/
public String getData() {
@@ -125,6 +140,7 @@ public class HockeyPlayer {
/**
* Compares this player to another object for equality based on name.
*
* @param o The object to compare.
* @return true if the names are equal, false otherwise.
*/
@@ -136,9 +152,10 @@ public class HockeyPlayer {
/**
* Compares this player to another for sorting purposes based on name.
*
* @param o The object to compare.
* @return A negative integer, zero, or a positive integer as this name
* is less than, equal to, or greater than the specified player's name.
* @return A negative integer, zero, or a positive integer as this name is less than, equal to, or
* greater than the specified player's name.
*/
public int compareTo(Object o) {
HockeyPlayer p = (HockeyPlayer) o;
@@ -147,6 +164,7 @@ public class HockeyPlayer {
/**
* Updates the player's career statistics by adding a new game's results.
*
* @param goals Number of goals scored in the game.
* @param assists Number of assists made in the game.
* @param gameWon True if the game resulted in a win, false if a loss.