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