Getters
for
the
name
(
String
),
number
of
points
(
int
),
and
number
of
wins
(
int
).
These
should be called
getName()
,
getScore()
, and
getWins()
, respectively.
•
A method
addPoints()
, which takes in an
int
and adds that number to the total number of
points the user has.
•
A method
resetScore()
, which takes no arguments and resets the player’s score to zero.
public class Player {
private String name;
private int score;
private int wins;
public String getName() {
return name;
}
public int getScore() {
return score;
}
public int getWins() {
return wins;
}
public void addPoints(int points) {
score += points;
}
public void resetScore() {
score = 0;
}
}
Comments
Leave a comment