More Error Handling for Score

This commit is contained in:
JJTCM 2014-11-11 13:19:41 +01:00
parent d36e1901e6
commit e928543e3f
2 changed files with 12 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package de.teamteamteam.spacescooter.datastructure;
public class Score {
private static int score = 0;
private static int maxScore = 99999999;
public static int getScore() {
return score;
@ -13,13 +14,19 @@ public class Score {
}
public static void addScore(int score) {
if (Score.score != 99999999)
if (Score.score + score >= Score.maxScore) {
Score.setScore(Score.maxScore);
} else if (Score.score != Score.maxScore) {
Score.score += score;
}
}
public static void removeScore(int score) {
if (Score.score != 0)
if (Score.score - score <= 0) {
Score.setScore(0);
} else if (Score.score != 0) {
Score.score -= score;
}
}
}