From 04931dfd9919b088df5214c3e4a741ed87d1e00a Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Wed, 1 Jul 2020 18:16:59 +0000 Subject: [PATCH] Apply suggestions from code review Co-authored-by: delvh --- src/main/dev/lh/Food.java | 8 ++++---- src/main/dev/lh/FoodFactory.java | 6 +++--- src/main/dev/lh/Handler.java | 4 ++-- src/main/dev/lh/Snake.java | 4 ++-- src/main/dev/lh/Updateable.java | 2 +- src/main/dev/lh/Viewport.java | 8 ++++---- src/main/dev/lh/ui/Endscreen.java | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/dev/lh/Food.java b/src/main/dev/lh/Food.java index d47fa77..484e21c 100644 --- a/src/main/dev/lh/Food.java +++ b/src/main/dev/lh/Food.java @@ -12,7 +12,7 @@ import java.awt.Rectangle; * Created: 01.07.2020
* * @author Kai S. K. Engelbart - * @since Snake 1.1 + * @since Snake 1.2 */ public final class Food implements Updateable { @@ -26,7 +26,7 @@ public final class Food implements Updateable { * @param color the color of the food item * @param lengthBonus the length added to the snake when the food item is eaten * @param bounds the bounds of the food item - * @since Snake 1.1 + * @since Snake 1.2 */ public Food(Color color, int lengthBonus, Rectangle bounds) { this.color = color; @@ -42,13 +42,13 @@ public final class Food implements Updateable { /** * @return the length added to the snake when the food item is eaten - * @since Snake 1.1 + * @since Snake 1.2 */ public int getLengthBonus() { return lengthBonus; } /** * @return the bounds of the food item - * @since Snake 1.1 + * @since Snake 1.2 */ public Rectangle getBounds() { return bounds; } } diff --git a/src/main/dev/lh/FoodFactory.java b/src/main/dev/lh/FoodFactory.java index e8aaa18..8811273 100755 --- a/src/main/dev/lh/FoodFactory.java +++ b/src/main/dev/lh/FoodFactory.java @@ -36,7 +36,7 @@ public final class FoodFactory { * * @param width the width of the viewport * @param height the height of the viewport - * @since Snake 1.1 + * @since Snake 1.2 */ public FoodFactory(int width, int height) { this.width = width; @@ -45,7 +45,7 @@ public final class FoodFactory { /** * @return a new food item - * @since Snake 1.1 + * @since Snake 1.2 */ public synchronized Food spawn() { nextSpawnTime = System.currentTimeMillis() + random.nextInt(15000) + 1000; @@ -63,7 +63,7 @@ public final class FoodFactory { /** * @return the time after which a new food item should be spawned - * @since Snake 1.1 + * @since Snake 1.2 */ public long getNextSpawnTime() { return nextSpawnTime; } } diff --git a/src/main/dev/lh/Handler.java b/src/main/dev/lh/Handler.java index 562ae0b..9c00d10 100644 --- a/src/main/dev/lh/Handler.java +++ b/src/main/dev/lh/Handler.java @@ -10,7 +10,7 @@ import java.awt.Graphics2D; * Created: 01.07.2020
* * @author Kai S. K. Engelbart - * @since Snake 1.1 + * @since Snake 1.2 */ public final class Handler implements Updateable { @@ -24,7 +24,7 @@ public final class Handler implements Updateable { * * @param snake the snake * @param foodFactory the food factory - * @since Snake 1.1 + * @since Snake 1.2 */ public Handler(Snake snake, FoodFactory foodFactory) { this.snake = snake; diff --git a/src/main/dev/lh/Snake.java b/src/main/dev/lh/Snake.java index a774a9b..f0fa54d 100644 --- a/src/main/dev/lh/Snake.java +++ b/src/main/dev/lh/Snake.java @@ -147,7 +147,7 @@ public class Snake implements Updateable { /** * @return the current {@link Direction} of the snake - * @since Snake 1.0 + * @since Snake 1.2 */ public Direction getDirection() { return direction; } @@ -159,7 +159,7 @@ public class Snake implements Updateable { /** * @return a rectangle representing the head of the snake - * @since Snake 1.1 + * @since Snake 1.2 */ public Rectangle getHead() { return tiles.get(0); } } diff --git a/src/main/dev/lh/Updateable.java b/src/main/dev/lh/Updateable.java index 1daa80d..87b3f7d 100755 --- a/src/main/dev/lh/Updateable.java +++ b/src/main/dev/lh/Updateable.java @@ -18,7 +18,7 @@ public interface Updateable { * Here should the actions be implemented that are supposed to happen when a new * frame gets created. * - * @since Snake 1.0 + * @since Snake 1.2 */ default void tick() {} diff --git a/src/main/dev/lh/Viewport.java b/src/main/dev/lh/Viewport.java index 943f3a7..874c436 100644 --- a/src/main/dev/lh/Viewport.java +++ b/src/main/dev/lh/Viewport.java @@ -14,7 +14,7 @@ import java.util.TimerTask; * Created: 01.07.2020
* * @author Kai S. K. Engelbart - * @since Snake 1.0 + * @since Snake 1.2 */ public class Viewport extends Canvas { @@ -33,7 +33,7 @@ public class Viewport extends Canvas { /** * @param gameRoot the game object responsible for updating the rest - * @since Snake 1.0 + * @since Snake 1.2 */ public Viewport(Updateable gameRoot) { this.gameRoot = gameRoot; @@ -43,7 +43,7 @@ public class Viewport extends Canvas { /** * Starts the render task. * - * @since Snake 1.1 + * @since Snake 1.2 */ public void start() { if (renderTask != null) @@ -72,7 +72,7 @@ public class Viewport extends Canvas { /** * Stops the render task. * - * @since Snake 1.1 + * @since Snake 1.2 */ public void stop() { renderTask.cancel(); diff --git a/src/main/dev/lh/ui/Endscreen.java b/src/main/dev/lh/ui/Endscreen.java index 1087106..56fdc07 100644 --- a/src/main/dev/lh/ui/Endscreen.java +++ b/src/main/dev/lh/ui/Endscreen.java @@ -32,7 +32,7 @@ public class Endscreen extends JDialog { public Endscreen(int score) { this.score = score; setTitle("Endscreen"); - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setBounds(100, 100, 700, 700); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));