Skip to content

Commit

Permalink
Solved checkStyle in GameState, GameStateImpl, SwingViewImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
sofialottii committed Feb 15, 2024
1 parent 124b866 commit 2ba2368
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/main/java/pvzclone/model/api/GameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ public interface GameState {

/**
* Sets the win state of the current game.
*
* @param winState the state of the current game.
*/
void setWinState(boolean winState);

/**
* Returns the win state at the end of the Game.
*
* @return true if player won, false if player lose, Optional.empty if game is not over.
* @return true if player won, false if player lose, Optional.empty if game is
* not over.
*/
Optional<Boolean> getWinState();
}
9 changes: 4 additions & 5 deletions src/main/java/pvzclone/model/impl/GameStateImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public final class GameStateImpl implements GameState {

private static final int INC_SUN = 25;
private final int INITIAL_SUNS = 100;
private static final int INITIAL_SUNS = 100;
private final int totZombies;
private int killedZombies;
private int zombiesGenerated;
Expand Down Expand Up @@ -75,16 +75,15 @@ public boolean areZombieAllKilled() {
}

@Override
public void setWinState(boolean winState) {
public void setWinState(final boolean winState) {
this.winState = Optional.of(winState);
}

@Override
public Optional<Boolean> getWinState() {
if(this.winState.isPresent()) {
if (this.winState.isPresent()) {
return this.winState;
}
else {
} else {
return Optional.empty();
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/pvzclone/view/impl/SwingViewImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public SwingViewImpl(final Controller controller) {
this.frame = new JFrame(APPLICATION_TITLE);
this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
public void windowClosing(final WindowEvent e) {
final int n = JOptionPane.showConfirmDialog(frame, "Do you really want to quit?",
"Quitting", JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.YES_OPTION) {
Expand All @@ -101,21 +101,21 @@ public void windowClosing(WindowEvent e) {
this.panel.addComponentListener(new ComponentListener() {

@Override
public void componentResized(ComponentEvent e) {
public void componentResized(final ComponentEvent e) {
scale = new Pair<>(e.getComponent().getWidth() / (double) APPLICATION_WIDTH,
e.getComponent().getHeight() / (double) APPLICATION_HEIGHT);
}

@Override
public void componentMoved(ComponentEvent e) {
public void componentMoved(final ComponentEvent e) {
}

@Override
public void componentShown(ComponentEvent e) {
public void componentShown(final ComponentEvent e) {
}

@Override
public void componentHidden(ComponentEvent e) {
public void componentHidden(final ComponentEvent e) {
}

});
Expand Down Expand Up @@ -181,7 +181,7 @@ public JFrame getFrame() {
}

@Override
public void endGame(Optional<Boolean> win) {
public void endGame(final Optional<Boolean> win) {
if (win.isEmpty()) {
throw new IllegalAccessError("Function not Accessible!");
} else {
Expand All @@ -190,7 +190,7 @@ public void endGame(Optional<Boolean> win) {
}

@Override
public final Pair<Double, Double> getScale() {
public Pair<Double, Double> getScale() {
return this.scale;
}
}

0 comments on commit 2ba2368

Please sign in to comment.