From 87048abd6fa6502c078345021fc7934e732f4e86 Mon Sep 17 00:00:00 2001 From: rxbn_ Date: Thu, 23 Jan 2020 18:45:36 +0100 Subject: [PATCH] Aufgabe 3 Feedback - minor fixes --- src/break_out/model/Level.java | 6 +++--- src/break_out/model/Paddle.java | 5 +++-- src/break_out/model/Stone.java | 9 ++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/break_out/model/Level.java b/src/break_out/model/Level.java index 261ffe8..c7e548c 100644 --- a/src/break_out/model/Level.java +++ b/src/break_out/model/Level.java @@ -42,7 +42,7 @@ public class Level extends Thread implements ILevel { /** * Flag that shows if the level was finished */ - private boolean levelFinished = false; + private boolean finished = false; /** * The paddles of the level @@ -127,7 +127,7 @@ public class Level extends Thread implements ILevel { game.notifyObservers(); // endless loop - while (!levelFinished) { + while (!finished) { // if ballWasStarted is true, the ball is moving if (ballWasStarted()) { @@ -240,7 +240,7 @@ public class Level extends Thread implements ILevel { * @param finished game state */ public void setFinished(boolean finished) { - this.levelFinished = finished; + this.finished = finished; } /** diff --git a/src/break_out/model/Paddle.java b/src/break_out/model/Paddle.java index 92d1ec1..3d4a845 100644 --- a/src/break_out/model/Paddle.java +++ b/src/break_out/model/Paddle.java @@ -136,9 +136,10 @@ public class Paddle implements IPaddle { * @param direction The paddles new direction */ public void setDirection(int direction) { + // normalization not needed // normalize to valid values - if(direction > 0) direction = 1; - if(direction < 0) direction = -1; + //if(direction > 0) direction = 1; + //if(direction < 0) direction = -1; this.direction = direction; } diff --git a/src/break_out/model/Stone.java b/src/break_out/model/Stone.java index 5871eb4..037cf31 100644 --- a/src/break_out/model/Stone.java +++ b/src/break_out/model/Stone.java @@ -112,10 +112,10 @@ public class Stone implements IStone { * @param type The stones new type */ public void setType(int type) { - // type not in range - if(type > 3) { type = 0; } - setValue(type); + + // set the type; no verification needed; this.type = type; + switch(type) { // multi-case, hacky, but dont care case 0: @@ -128,14 +128,17 @@ public class Stone implements IStone { case 1: // stone type one setColor(Color.CYAN); + setValue(1); break; case 2: // stone type two setColor(Color.WHITE); + setValue(2); break; case 3: // stone type three setColor(Color.BLUE); + setValue(3); break; } }