Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
Kai S. K. Engelbart 2020-07-01 18:16:59 +00:00 committed by GitHub
parent 7c55e049cf
commit 04931dfd99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 17 deletions

View File

@ -12,7 +12,7 @@ import java.awt.Rectangle;
* Created: <strong>01.07.2020</strong><br> * Created: <strong>01.07.2020</strong><br>
* *
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since Snake 1.1 * @since Snake 1.2
*/ */
public final class Food implements Updateable { 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 color the color of the food item
* @param lengthBonus the length added to the snake when the food item is eaten * @param lengthBonus the length added to the snake when the food item is eaten
* @param bounds the bounds of the food item * @param bounds the bounds of the food item
* @since Snake 1.1 * @since Snake 1.2
*/ */
public Food(Color color, int lengthBonus, Rectangle bounds) { public Food(Color color, int lengthBonus, Rectangle bounds) {
this.color = color; 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 * @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; } public int getLengthBonus() { return lengthBonus; }
/** /**
* @return the bounds of the food item * @return the bounds of the food item
* @since Snake 1.1 * @since Snake 1.2
*/ */
public Rectangle getBounds() { return bounds; } public Rectangle getBounds() { return bounds; }
} }

View File

@ -36,7 +36,7 @@ public final class FoodFactory {
* *
* @param width the width of the viewport * @param width the width of the viewport
* @param height the height of the viewport * @param height the height of the viewport
* @since Snake 1.1 * @since Snake 1.2
*/ */
public FoodFactory(int width, int height) { public FoodFactory(int width, int height) {
this.width = width; this.width = width;
@ -45,7 +45,7 @@ public final class FoodFactory {
/** /**
* @return a new food item * @return a new food item
* @since Snake 1.1 * @since Snake 1.2
*/ */
public synchronized Food spawn() { public synchronized Food spawn() {
nextSpawnTime = System.currentTimeMillis() + random.nextInt(15000) + 1000; 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 * @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; } public long getNextSpawnTime() { return nextSpawnTime; }
} }

View File

@ -10,7 +10,7 @@ import java.awt.Graphics2D;
* Created: <strong>01.07.2020</strong><br> * Created: <strong>01.07.2020</strong><br>
* *
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since Snake 1.1 * @since Snake 1.2
*/ */
public final class Handler implements Updateable { public final class Handler implements Updateable {
@ -24,7 +24,7 @@ public final class Handler implements Updateable {
* *
* @param snake the snake * @param snake the snake
* @param foodFactory the food factory * @param foodFactory the food factory
* @since Snake 1.1 * @since Snake 1.2
*/ */
public Handler(Snake snake, FoodFactory foodFactory) { public Handler(Snake snake, FoodFactory foodFactory) {
this.snake = snake; this.snake = snake;

View File

@ -147,7 +147,7 @@ public class Snake implements Updateable {
/** /**
* @return the current {@link Direction} of the snake * @return the current {@link Direction} of the snake
* @since Snake 1.0 * @since Snake 1.2
*/ */
public Direction getDirection() { return direction; } public Direction getDirection() { return direction; }
@ -159,7 +159,7 @@ public class Snake implements Updateable {
/** /**
* @return a rectangle representing the head of the snake * @return a rectangle representing the head of the snake
* @since Snake 1.1 * @since Snake 1.2
*/ */
public Rectangle getHead() { return tiles.get(0); } public Rectangle getHead() { return tiles.get(0); }
} }

View File

@ -18,7 +18,7 @@ public interface Updateable {
* Here should the actions be implemented that are supposed to happen when a new * Here should the actions be implemented that are supposed to happen when a new
* frame gets created. * frame gets created.
* *
* @since Snake 1.0 * @since Snake 1.2
*/ */
default void tick() {} default void tick() {}

View File

@ -14,7 +14,7 @@ import java.util.TimerTask;
* Created: <strong>01.07.2020</strong><br> * Created: <strong>01.07.2020</strong><br>
* *
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since Snake 1.0 * @since Snake 1.2
*/ */
public class Viewport extends Canvas { public class Viewport extends Canvas {
@ -33,7 +33,7 @@ public class Viewport extends Canvas {
/** /**
* @param gameRoot the game object responsible for updating the rest * @param gameRoot the game object responsible for updating the rest
* @since Snake 1.0 * @since Snake 1.2
*/ */
public Viewport(Updateable gameRoot) { public Viewport(Updateable gameRoot) {
this.gameRoot = gameRoot; this.gameRoot = gameRoot;
@ -43,7 +43,7 @@ public class Viewport extends Canvas {
/** /**
* Starts the render task. * Starts the render task.
* *
* @since Snake 1.1 * @since Snake 1.2
*/ */
public void start() { public void start() {
if (renderTask != null) if (renderTask != null)
@ -72,7 +72,7 @@ public class Viewport extends Canvas {
/** /**
* Stops the render task. * Stops the render task.
* *
* @since Snake 1.1 * @since Snake 1.2
*/ */
public void stop() { public void stop() {
renderTask.cancel(); renderTask.cancel();

View File

@ -32,7 +32,7 @@ public class Endscreen extends JDialog {
public Endscreen(int score) { public Endscreen(int score) {
this.score = score; this.score = score;
setTitle("Endscreen"); setTitle("Endscreen");
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setBounds(100, 100, 700, 700); setBounds(100, 100, 700, 700);
getContentPane().setLayout(new BorderLayout()); getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));