From c61f6daeba2a67a0480d651fb543e5ac746f54ab Mon Sep 17 00:00:00 2001 From: Francesco Agostinelli <56121733+Weebli@users.noreply.github.com> Date: Thu, 24 Jun 2021 09:04:50 +0200 Subject: [PATCH 1/2] Added a constant --- src/main/java/bomberone/views/rank/RankViewImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/bomberone/views/rank/RankViewImpl.java b/src/main/java/bomberone/views/rank/RankViewImpl.java index 97c5fa84..6c68c7fb 100644 --- a/src/main/java/bomberone/views/rank/RankViewImpl.java +++ b/src/main/java/bomberone/views/rank/RankViewImpl.java @@ -49,6 +49,11 @@ public final class RankViewImpl extends ViewImpl implements RankView { */ private static final int BUTTONS_IMAGES = 2; + /** + * This constant indicates the default selected rank. + */ + private static final int DEFAULT_RANK = 0; + private int currentRank; private Image[] rankDifficultyImages; private Image[] imagesPrevButtons; @@ -111,7 +116,7 @@ public void init() { try { this.currentRank = ((RankController) this.getController()).getMatchDifficulty().ordinal(); } catch(Exception e) { - this.currentRank = Difficulty.EASY.ordinal(); + this.currentRank = RankViewImpl.DEFAULT_RANK; } this.imageViewDifficulty.setImage(this.rankDifficultyImages[this.currentRank]); From c22034b8d162968152ff543c62d7a82e20dc3dcd Mon Sep 17 00:00:00 2001 From: LuigiBorriello Date: Thu, 24 Jun 2021 13:01:46 +0200 Subject: [PATCH 2/2] remove warnings --- src/main/java/bomberone/model/enemy/EnemyImpl.java | 2 +- .../bomberone/model/enemy/actions/HardBehavior.java | 1 + .../java/bomberone/model/pathfinding/BFSSearch.java | 4 ++-- .../model/pathfinding/gameboard/GameBoard.java | 2 +- src/main/java/bomberone/views/rank/RankViewImpl.java | 11 +++++------ .../bomberone/model/pathfinding/TestPathfinding.java | 5 ++++- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/bomberone/model/enemy/EnemyImpl.java b/src/main/java/bomberone/model/enemy/EnemyImpl.java index 93e8abca..3142120e 100644 --- a/src/main/java/bomberone/model/enemy/EnemyImpl.java +++ b/src/main/java/bomberone/model/enemy/EnemyImpl.java @@ -38,7 +38,7 @@ public final class EnemyImpl extends MoveableObjectImpl implements Enemy { private static final int SECONDS_TO_WAIT = 4; /** - * This constant is the number of frames per second + * This constant is the number of frames per second. */ private static final int FRAME_PER_SECOND = 60; diff --git a/src/main/java/bomberone/model/enemy/actions/HardBehavior.java b/src/main/java/bomberone/model/enemy/actions/HardBehavior.java index c46c8ebd..b9e3afb5 100644 --- a/src/main/java/bomberone/model/enemy/actions/HardBehavior.java +++ b/src/main/java/bomberone/model/enemy/actions/HardBehavior.java @@ -21,6 +21,7 @@ public final class HardBehavior extends AbstractActions { * Creates a new IntermediateBehavior object. * * @param newEnemy The enemy that uses this behavior. + * @param finder */ public HardBehavior(final Enemy newEnemy, final PathFinder finder) { super(newEnemy); diff --git a/src/main/java/bomberone/model/pathfinding/BFSSearch.java b/src/main/java/bomberone/model/pathfinding/BFSSearch.java index 3f853c94..6f117f26 100644 --- a/src/main/java/bomberone/model/pathfinding/BFSSearch.java +++ b/src/main/java/bomberone/model/pathfinding/BFSSearch.java @@ -27,7 +27,7 @@ public final class BFSSearch implements PathFinder { * * @param map The game map. */ - public BFSSearch(GameBoard map) { + public BFSSearch(final GameBoard map) { this.map = map; this.exploredNodes = new LinkedList(); this.discoveredNodes = new LinkedList(); @@ -37,7 +37,7 @@ public BFSSearch(GameBoard map) { * {@inheritDoc} */ @Override - public void setMap(GameBoard newMap) { + public void setMap(final GameBoard newMap) { this.map = newMap; } diff --git a/src/main/java/bomberone/model/pathfinding/gameboard/GameBoard.java b/src/main/java/bomberone/model/pathfinding/gameboard/GameBoard.java index 6a674b1e..7acb3ae9 100644 --- a/src/main/java/bomberone/model/pathfinding/gameboard/GameBoard.java +++ b/src/main/java/bomberone/model/pathfinding/gameboard/GameBoard.java @@ -327,7 +327,7 @@ public void changeAllItems(final Markers markerToChange, final Markers newMarker * * @param points A List objects that have to get the marker * changed. - * @param newMarker The new marker. + * */ public void changeAllItems(final List points) { boolean result; diff --git a/src/main/java/bomberone/views/rank/RankViewImpl.java b/src/main/java/bomberone/views/rank/RankViewImpl.java index 6c68c7fb..dcc0ee5a 100644 --- a/src/main/java/bomberone/views/rank/RankViewImpl.java +++ b/src/main/java/bomberone/views/rank/RankViewImpl.java @@ -24,7 +24,6 @@ import bomberone.views.ViewType; import bomberone.views.ViewsSwitcher; import bomberone.controllers.rank.RankController; -import bomberone.model.match.Difficulty; import bomberone.model.user.User; import javafx.scene.image.Image; @@ -115,14 +114,14 @@ public void init() { // Setting the initial rank to show. try { this.currentRank = ((RankController) this.getController()).getMatchDifficulty().ordinal(); - } catch(Exception e) { + } catch (Exception e) { this.currentRank = RankViewImpl.DEFAULT_RANK; } this.imageViewDifficulty.setImage(this.rankDifficultyImages[this.currentRank]); this.tableView.setItems(this.ranks.get(this.currentRank)); } - + /** * {@inheritDoc} */ @@ -291,7 +290,7 @@ public void changeRank(final boolean next) { this.imageViewDifficulty.setImage(this.rankDifficultyImages[this.currentRank]); this.tableView.setItems(this.ranks.get(this.currentRank)); } - + /** * {@inheritDoc} */ @@ -299,7 +298,7 @@ public void changeRank(final boolean next) { public void onBackToMainMenuClicked() { ViewsSwitcher.getInstance().switchView(this.getStage(), ViewType.HOME, this.getController().getModel()); } - + /** * {@inheritDoc} */ @@ -307,7 +306,7 @@ public void onBackToMainMenuClicked() { public void onNextClicked() { this.changeRank(true); } - + /** * {@inheritDoc} */ diff --git a/src/test/java/bomberone/model/pathfinding/TestPathfinding.java b/src/test/java/bomberone/model/pathfinding/TestPathfinding.java index 24a53fc0..25ecae5a 100644 --- a/src/test/java/bomberone/model/pathfinding/TestPathfinding.java +++ b/src/test/java/bomberone/model/pathfinding/TestPathfinding.java @@ -40,10 +40,13 @@ public class TestPathfinding { */ private static final int POS_1 = 1; - BoardPoint startPosition; + private BoardPoint startPosition; private PathFinder pathFinder; private GameBoard testBoard; + /** + * + */ @BeforeEach public void init() { List> boardToSet = new LinkedList>();