everything basically
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
public class HockeyPlayer {
|
||||
String name;
|
||||
int goals, assists, gamesWon, gamesLost;
|
||||
|
||||
public HockeyPlayer(String n, int g, int a, int gw, int gl) {
|
||||
name = n;
|
||||
goals = g;
|
||||
assists = a;
|
||||
gamesWon = gw;
|
||||
gamesLost = gl;
|
||||
}
|
||||
|
||||
public HockeyPlayer(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return goals + assists;
|
||||
}
|
||||
|
||||
public int getGamesPlayed() {
|
||||
return gamesWon + gamesLost;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String s =
|
||||
String.format(
|
||||
"Name: %s%nGoals: %d%tAssists: %d%tPoints: %d%nGames Won: %d%tGames Lost: %d%tGames"
|
||||
+ " Played: %d%n",
|
||||
name, goals, assists, getPoints(), gamesWon, gamesLost, getGamesPlayed());
|
||||
return s;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
HockeyPlayer p = (HockeyPlayer) o;
|
||||
return this.name.equals(p.name);
|
||||
}
|
||||
|
||||
public int compareTo(Object o) {
|
||||
HockeyPlayer p = (HockeyPlayer) o;
|
||||
return this.name.compareTo(p.name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user