-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalcScore.java
More file actions
42 lines (37 loc) · 1.13 KB
/
CalcScore.java
File metadata and controls
42 lines (37 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package part;
public class CalcScore {
public static void main(String[] args) {
boolean gameOver = true;
int score = 200;
int level = 5;
int bonus = 188;
calculateScore(gameOver, score, level, bonus);
displayHighScore("John", calculateHighScorePosition(1500));
displayHighScore("Jesse", calculateHighScorePosition(900));
displayHighScore("Rick", calculateHighScorePosition(400));
displayHighScore("Bob", calculateHighScorePosition(50));
}
public static int calculateScore(boolean gameOver, int score, int level, int bonus) {
if(gameOver) {
int finalScore = score + (level * bonus);
finalScore += 2000;
System.out.println("Your final score was " + finalScore);
return finalScore;
}
return -1;
}
public static void displayHighScore(String name, int position) {
System.out.println(name + "\t has managed to get in position " + position + " on the high score table.");
}
public static int calculateHighScorePosition(int score) {
int position = 4;
if(score >= 1000) {
position = 1;
} else if(score >= 500) {
position = 2;
} else if(score >= 100) {
position = 3;
}
return position;
}
}