diff --git a/src/main/java/pvzclone/model/api/GameState.java b/src/main/java/pvzclone/model/api/GameState.java index 1d9e7ed..a138cce 100644 --- a/src/main/java/pvzclone/model/api/GameState.java +++ b/src/main/java/pvzclone/model/api/GameState.java @@ -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 getWinState(); } diff --git a/src/main/java/pvzclone/model/impl/GameStateImpl.java b/src/main/java/pvzclone/model/impl/GameStateImpl.java index aa1c974..90c41d2 100644 --- a/src/main/java/pvzclone/model/impl/GameStateImpl.java +++ b/src/main/java/pvzclone/model/impl/GameStateImpl.java @@ -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; @@ -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 getWinState() { - if(this.winState.isPresent()) { + if (this.winState.isPresent()) { return this.winState; - } - else { + } else { return Optional.empty(); } } diff --git a/src/main/java/pvzclone/view/impl/SwingViewImpl.java b/src/main/java/pvzclone/view/impl/SwingViewImpl.java index ceaf5bb..077eba8 100644 --- a/src/main/java/pvzclone/view/impl/SwingViewImpl.java +++ b/src/main/java/pvzclone/view/impl/SwingViewImpl.java @@ -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) { @@ -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) { } }); @@ -181,7 +181,7 @@ public JFrame getFrame() { } @Override - public void endGame(Optional win) { + public void endGame(final Optional win) { if (win.isEmpty()) { throw new IllegalAccessError("Function not Accessible!"); } else { @@ -190,7 +190,7 @@ public void endGame(Optional win) { } @Override - public final Pair getScale() { + public Pair getScale() { return this.scale; } }