1 package se
.umu
.cs
.dit06ajnajs
;
4 * Player is used to represent a player of the game.
6 * @author Anton Johansson (dit06ajn@cs.umu.se)
7 * @author Andreas Jakobsson (dit06ajs@cs.umu.se)
15 private int currentLevel
;
16 private int savedScore
;
20 * Creates a new unnamed <code>Player</code>, score, savedScore,
21 * currentLevel is set to 0. An initial credit is given.
24 this.name
= "Unnamed player";
27 this.currentLevel
= 0;
32 * Sets the name of this player.
34 * @param name The name of this player.
36 public void setName(String name
) {
41 * Returns the name of this player.
43 * @return The name of this player.
45 public String
getName() {
50 * Adds credit to this player. Score is increased.
52 * @param credit The credit to add.
54 public void addCredit(int credit
) {
55 this.credit
+= credit
;
60 * Remove credit from this player.
62 * @param credit Amount of credit to remove.
64 public void removeCredit(int credit
) {
65 this.credit
-= credit
;
68 /** Sets an initial value of credits. */
69 public void initCredit() {
74 * Set the level number to play.
76 * @param num The level number to play.
78 public void setCurrentLevel(int num
) {
79 this.currentLevel
= num
;
83 * Save the current score to saved score.
85 public void saveScore() {
86 this.savedScore
= score
;
90 * Resets the current score to the last saved score
92 public void loadSavedScore() {
93 this.score
= this.savedScore
;
97 * Return the saved score.
99 * @return The saved score.
101 public int getSavedScore() {
102 return this.savedScore
;
106 * Return players credit.
108 * @return Players credit.
110 public int getCredit() {
115 * Return the score of this player.
117 * @return The score of this player.
119 public int getScore() {
124 * Return the level number this player is at.
126 * @return The level number this player is at.
128 public int getCurrentLevel() {
129 return this.currentLevel
;