From aabd78684b66809a082756966c7e9727e4b3090b Mon Sep 17 00:00:00 2001 From: Josh Alejandro <jalejand@myune.edu.au> Date: Tue, 19 Sep 2023 22:49:18 +1000 Subject: [PATCH] Added Skeleton for ScoringSystem class --- .../main/java/brickbreaker/ScoringSystem.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/src/main/java/brickbreaker/ScoringSystem.java diff --git a/app/src/main/java/brickbreaker/ScoringSystem.java b/app/src/main/java/brickbreaker/ScoringSystem.java new file mode 100644 index 0000000..d55638f --- /dev/null +++ b/app/src/main/java/brickbreaker/ScoringSystem.java @@ -0,0 +1,39 @@ +public class ScoringSystem { + private int score; // Current Score + private int highScore; // Highest Score + private static final int POINTS = 1; // Point Value + + public ScoringSystem() { + this.score = 0; + this.highScore = 0; + } + + // Add point to each broken brick + public void brickBroken() { + score += POINTS; + checkForNewHighScore(); + } + + // Compare Current Score and highest score + private void checkForNewHighScore() { + if (score > highScore) { + highScore = score; + } + } + + // Reset score + public void resetScore() { + score = 0; + } + + // Getters + public int getScore() { + return score; + } + + public int getHighScore() { + return highScore; + } +} + + -- GitLab