Javadoc, small bugfix in levels.xml
[AntiTD.git] / src / se / umu / cs / dit06ajnajs / Player.java
blobcc2701c8f9d58f8a569f1a334d1b62b6651466ff
1 package se.umu.cs.dit06ajnajs;
3 /**
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)
8 * @version 1.0
9 */
10 public class Player {
12 private String name;
13 private int credit;
14 private int score;
15 private int currentLevel;
16 private int savedScore;
19 /**
20 * Creates a new unnamed <code>Player</code>, score, savedScore,
21 * currentLevel is set to 0. An initial credit is given.
23 public Player() {
24 this.name = "Unnamed player";
25 this.score = 0;
26 this.savedScore = 0;
27 this.currentLevel = 0;
28 initCredit();
31 /**
32 * Sets the name of this player.
34 * @param name The name of this player.
36 public void setName(String name) {
37 this.name = name;
40 /**
41 * Returns the name of this player.
43 * @return The name of this player.
45 public String getName() {
46 return this.name;
49 /**
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;
56 this.score += credit;
59 /**
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() {
70 this.credit = 5000;
73 /**
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;
82 /**
83 * Save the current score to saved score.
85 public void saveScore() {
86 this.savedScore = score;
89 /**
90 * Resets the current score to the last saved score
92 public void loadSavedScore() {
93 this.score = this.savedScore;
96 /**
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() {
111 return this.credit;
115 * Return the score of this player.
117 * @return The score of this player.
119 public int getScore() {
120 return this.score;
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;