Modifier and Type | Field and Description |
---|---|
(package private) int |
highScore
Declared high_score variable to findOut high score among players
and It helps us to announce the winner after scoring 100
|
(package private) char |
key |
private java.util.logging.Logger |
logger |
(package private) int |
oldScore
Declared old_score variable to assign default score to players
|
private static java.util.Random |
random |
private static java.util.Map<java.lang.String,java.lang.Integer> |
scoreMap
created map object with null value to create single object through getMap() method
In map we are going to store player_names and player_scores.
|
(package private) static int |
winValue |
Constructor and Description |
---|
Player() |
Modifier and Type | Method and Description |
---|---|
void |
getMap()
getMap() method for create object to the map
and same time it will add default player names and scores
|
int |
roleDice()
roleDice() method gives random number between to 1 to 6 when role the dice
|
void |
showScore()
showScore() method shows score of each player and it will announce the winner
|
void |
startGame()
startGame() method it starts the game and this method executes untill one player got 100 score
It will scan r character to role dice
roleDice() get called to get random number
updateScore() get called to update score
showScore() get called to show the update score to the players
|
int |
updateScore(java.lang.String playerName,
int addScore)
updateScore() this method goes to update the score after rolling the dice
|
private static java.util.Map<java.lang.String,java.lang.Integer> scoreMap
private static java.util.Random random
private java.util.logging.Logger logger
int oldScore
int highScore
static final int winValue
char key
public int roleDice()
public void getMap()
public int updateScore(java.lang.String playerName, int addScore)
updateScore
in interface Dice
playerName
- addScore
- public void showScore()
public void startGame()