More Error Handling for Score
This commit is contained in:
parent
d36e1901e6
commit
e928543e3f
@ -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)
|
||||
Score.score += score;
|
||||
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)
|
||||
Score.score -= score;
|
||||
if (Score.score - score <= 0) {
|
||||
Score.setScore(0);
|
||||
} else if (Score.score != 0) {
|
||||
Score.score -= score;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user