update HockeyPlayer javadocs
This commit is contained in:
@@ -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,43 +38,52 @@ public class HockeyPlayer {
|
||||
|
||||
/**
|
||||
* getName gets the player's name
|
||||
* @return 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.
|
||||
/**
|
||||
* getGoals gets the player's total goals scored
|
||||
*
|
||||
* @return Total goals scored.
|
||||
*/
|
||||
public int getGoals() {
|
||||
return goals;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* getAssists gets the player's total assists recorded
|
||||
* @return Total assists recorded.
|
||||
*
|
||||
* @return Total assists recorded.
|
||||
*/
|
||||
public int getAssists() {
|
||||
return assists;
|
||||
}
|
||||
|
||||
/**
|
||||
* getGamesWon gets the player's total games won
|
||||
* @return Total games won.
|
||||
* 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.
|
||||
@@ -157,4 +175,4 @@ public class HockeyPlayer {
|
||||
if (gameWon) gamesWon++;
|
||||
else gamesLost++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user