Skip to content

Commit 226b341

Browse files
authored
Update GameApp.java
1 parent a8a55ba commit 226b341

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

code/GameApp.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,33 @@
1-
public class GameApp {
1+
public class Main {
22
public static void main(String[] args) {
33
Player alice = new Player("Alice", new int[] {10, 15, 20});
44
Player bob = new Player("Bob", new int[] {5, 7});
5-
Player charlie = new Player("Charlie", new int[] {}); // empty scores
5+
Player charlie = new Player("Charlie", new int[] {});
66

77
System.out.println("=== Scoreboard ===");
88

99
printPlayerStats(alice);
1010
printPlayerStats(bob);
1111
printPlayerStats(charlie);
1212

13-
// Intentionally pass a null player to show a null‑related bug
1413
Player mystery = null;
1514
System.out.println("\nMystery total score (should handle null):");
1615
int total = ScoreUtils.totalScore(mystery);
1716
System.out.println("Total: " + total);
18-
19-
// Level Loader demo for Level 4
20-
demoLevels();
2117
}
2218

2319
private static void printPlayerStats(Player player) {
2420
int[] scores = player.getScores();
21+
int scoreLength = (scores == null) ? 0 : scores.length;
2522

2623
double avg = ScoreUtils.averageScore(scores);
2724
int best = ScoreUtils.bestScore(scores);
28-
int total = ScoreUtils.totalScore(player);
25+
int lineTotal = ScoreUtils.totalScore(player);
2926

3027
System.out.println("Player: " + player.getName());
3128
System.out.println(" Average: " + avg);
3229
System.out.println(" Best: " + best);
33-
System.out.println(" Total: " + total);
30+
System.out.println(" Total: " + lineTotal);
3431
System.out.println();
3532
}
36-
37-
private static void demoLevels() {
38-
System.out.println("=== Level Loader Demo ===");
39-
40-
String input = "level: 4"; // note the space before 4
41-
System.out.println("Parsing input: \"" + input + "\"");
42-
43-
int level = InputParser.parseLevel(input);
44-
System.out.println("Parsed level: " + level);
45-
46-
int[] enemies = LevelLoader.loadEnemiesForLevel(level);
47-
int difficulty = LevelLoader.computeDifficulty(enemies);
48-
49-
System.out.println("Total difficulty for level " + level + ": " + difficulty);
50-
}
5133
}
52-

0 commit comments

Comments
 (0)