Skip to content

Commit

Permalink
Fixed All Remaining Gradlew Check Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomarrelli committed Feb 16, 2024
1 parent 5375c41 commit 491b0a3
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/main/java/pvzclone/controller/api/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public interface Controller {
/**
* Sets the number of the Level to the number of the argument passed.
*
* @param numberOfTheLevel
* @param numberOfTheLevel level index.
*/
void chooseLevel(int numberOfTheLevel);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pvzclone/model/api/GameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface GameState {
int getZombiesGenerated();

/**
* @return {@true} number of zombies killed is equals
* @return if number of zombies killed is equals
* to the effective number to be killed.
*/
boolean areZombieAllKilled();
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/pvzclone/model/impl/LevelImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,55 +40,55 @@ public LevelImpl(final int zombieCount, final int zombieWaveCount,
}

/**
* @see {@link Level#getZombieCount()}
* @see Level#getZombieCount()
*/
@Override
public int getZombieCount() {
return this.zombieCount;
}

/**
* @see {@link Level#getZombieWaveCount()}
* @see Level#getZombieWaveCount()
*/
@Override
public int getZombieWaveCount() {
return this.zombieWaveCount;
}

/**
* @see {@link Level#getZombieCountInWave()}
* @see Level#getZombieCountInWave()
*/
@Override
public int getZombieCountInWave() {
return (int) (this.getZombieCount() * WAVE_PERCENTAGE) / 100;
}

/**
* @see {@link Level#getSunSpawnRate()}
* @see Level#getSunSpawnRate()
*/
@Override
public long getSunSpawnRate() {
return this.sunSpawnRate;
}

/**
* @see {@link Level#getZombieSpawnRate()}
* @see Level#getZombieSpawnRate()
*/
@Override
public long getZombieSpawnRate() {
return this.zombieSpawnRate;
}

/**
* @see {@link Level#getSunSpawnRateDecrementRange()}
* @see Level#getSunSpawnRateDecrementRange()
*/
@Override
public long getSunSpawnRateDecrementRange() {
return this.sunSpawnRateDecrementRange;
}

/**
* @see {@link Level#getZombieSpawnRateDecrementRange()}
* @see Level#getZombieSpawnRateDecrementRange()
*/
@Override
public long getZombieSpawnRateDecrementRange() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/pvzclone/model/impl/LevelsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public int getLevelCount() {
* @return the number of levels.
*/
public LevelImpl createLevel(final int delta) {
if (delta < 0 || delta >= MAX_LEVELS) {
throw new IllegalArgumentException("Invalid delta: '" + delta + "'!");
}

return new LevelImpl(
LevelsManager.ZOMBIE_COUNT
+ (LevelsManager.ZOMBIE_COUNT_STEP * delta),
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/pvzclone/model/impl/Pair.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.util.Objects;

/**
* A standard generic Pair<X,Y>, with getters, hashCode, equals, and toString
* well implemented.
* A standard generic Pair&lt;X,Y&gt;.
* It comprehends getters, hashCode, equals, and toString.
*
* @param <X> first element type.
* @param <Y> second element type.
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/pvzclone/view/impl/FieldCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,32 @@
* The center of the cell is saved and its bounds will be calculated
* using the constants declared inside {@link GamePanel}
*
* @see {@link GamePanel}
* @see GamePanel
* @author Marco Marrelli
*/
@SuppressFBWarnings(value = {
"EI_EXPOSE_REP2"
}, justification = "parent is intended to be modified")
}, justification = "Parent is Intended to be Modified.")
public class FieldCell extends JButton {
private static final long serialVersionUID = 1234500005L;

/** Cell Text Initializer, used for {@link JButton#JButton(String)}. */
public static final String CELL_TEXT_INITIALIZER = "";

private final GamePanel parent;
private final transient Pair<Integer, Integer> coord;
private final transient Controller controller;

/** The Game Panel (the parent). */
private final GamePanel parent;

/** The Color for the Hover on the Cell. */
private final Color hoverColor = new Color(225, 215, 235);

/** The Border Settings for the Hover on the Cell. */
private final Border hoverBorder = new LineBorder(hoverColor, 3);

/** If the Cell has a Plant or Not. */
private boolean hasPlant;
private final transient Controller controller;

/**
* Field Cell Constructor.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/pvzclone/view/impl/FieldCellListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Mouse Event Listener for the {@link FieldCell} Component.
*
* @see {@link FieldCell}
* @see FieldCell
* @author Marco Marrelli
*/

Expand All @@ -29,14 +29,14 @@ public FieldCellListener(final FieldCell parent) {
}

/**
* @see {@link FieldCellListener#muouseReleased()}
* @see FieldCellListener#mouseReleased(MouseEvent)
*/
@Override
public void mouseClicked(final MouseEvent e) {
}

/**
* @see {@link FieldCellListener#muouseReleased()}
* @see FieldCellListener#mouseReleased(MouseEvent)
*/
@Override
public void mousePressed(final MouseEvent e) {
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/pvzclone/view/impl/GamePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,35 @@ public final class GamePanel extends GenericPanel {
private static final int SUN_ENTITY_WIDTH = 140;
private static final int SUN_ENTITY_HEIGHT = 106;

private final transient Map<Entities, ImageIcon> entities = new HashMap<>();

private final transient Set<Pair<ImageIcon, Pair<Integer, Integer>>> images = new HashSet<>();

private final transient SwingViewImpl parent;

private transient Pair<Double, Double> scale;

/** Field Cell Width. */
public static final int CELL_WIDTH = X_OFFSET - X_MARGIN;

/** Field Cell Height. */
public static final int CELL_HEIGHT = Y_OFFSET - Y_MARGIN;

/** Cell Matrix on the Game Field. */
private final FieldCell[][] fieldMatrix;

/** Show how many suns the player has. */
private final JLabel points;

private final transient Map<Entities, ImageIcon> entities = new HashMap<>();
private final transient Set<Pair<ImageIcon, Pair<Integer, Integer>>> images = new HashSet<>();

/** Flag checking if the user is planting or not. */
private boolean userIsPlanting;

private final transient SwingViewImpl parent;

private transient Pair<Double, Double> scale;

/**
* Game Panel Constructor.
*
* @param parent the application's view.
* @param backgroundSource the background image source.
* @see {@link GenericPanel}
* @see GenericPanel
*/
public GamePanel(final SwingViewImpl parent, final String backgroundSource) {
super(parent, backgroundSource);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pvzclone/view/impl/LevelPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class LevelPanel extends GenericPanel {
*
* @param parent the application's view.
* @param backgroundSource the background image source.
* @see {@link GenericPanel}
* @see GenericPanel
*/
public LevelPanel(final SwingViewImpl parent, final String backgroundSource) {
super(parent, backgroundSource);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pvzclone/view/impl/MenuPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class MenuPanel extends GenericPanel {
*
* @param parent the application's view.
* @param backgroundSource the background image source.
* @see {@link GenericPanel}
* @see GenericPanel
*/
public MenuPanel(final SwingViewImpl parent, final String backgroundSource) {
super(parent, backgroundSource);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pvzclone/view/impl/SwingViewImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public String getSceneConstraint() {
/**
* Updates the View.
*
* @see {@link pvzclone.view.impl.GenericPanel#paintComponents(java.awt.Graphics)}
* @see pvzclone.view.impl.GenericPanel#paintComponents(java.awt.Graphics)
*/
@Override
public void update() {
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/pvzclone/LevelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
import static org.junit.jupiter.api.Assertions.assertTrue;

//import java.util.List;
//import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Optional;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -40,7 +40,7 @@ void checkLevelGenerationLimits() {
void checkCreatedLevel() {
assertEquals(this.correctLevelManager.createLevel(0).getClass(), LevelImpl.class);

//assertThrowsExactly(IllegalArgumentException.class, () -> this.correctLevelManager.createLevel(-1));
assertThrowsExactly(IllegalArgumentException.class, () -> this.correctLevelManager.createLevel(-1));
}

@Test
Expand All @@ -60,6 +60,6 @@ void checkLevelListGetter() {
assertFalse(this.correctLevelManager.getLevelList().isEmpty());

assertEquals(this.correctLevelManager.getLevelList().size(), this.correctLevelManager.getLevelCount());
//assertEquals(this.correctLevelManager.getLevelList().getClass(), ArrayList.class);
assertTrue(this.correctLevelManager.getLevelList() instanceof ArrayList);
}
}

0 comments on commit 491b0a3

Please sign in to comment.