Skip to content

Commit

Permalink
Style Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ragnarok540 committed Mar 3, 2023
1 parent 39dea70 commit e1c2bb0
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 64 deletions.
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.2.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
35 changes: 18 additions & 17 deletions src/main/java/edu/patterns/gui/QuickStartDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
import edu.patterns.player.MementoPlayer;
import edu.patterns.player.NullPlayer;

public class QuickStartDialog extends JDialog implements PropertyChangeListener {
public final class QuickStartDialog extends JDialog
implements PropertyChangeListener {

private static final long serialVersionUID = 1L;

private static final int WIDTH = 320;
private static final int HEIGHT = 160;
private static final int NICK_TF_LENGHT = 10;
private static final int MAX_NICK_LENGHT = 6;
private JOptionPane optionPane;
private JTextField tfNickName;
private String nickName;
private Game game;

public QuickStartDialog(JFrame window, Game game) {
public QuickStartDialog(final JFrame window, final Game game) {
super(window, true);
this.game = game;
setTitle(Const.T_INGR);


tfNickName = new JTextField(10);

tfNickName = new JTextField(NICK_TF_LENGHT);
Object[] msg = {Const.T_NICKRAPIDO, tfNickName};
Object[] options = {Const.T_INIC, Const.CANCELAR};

Expand All @@ -47,20 +48,20 @@ public QuickStartDialog(JFrame window, Game game) {
setContentPane(optionPane);

addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent ce) {
public void componentShown(final ComponentEvent ce) {
tfNickName.requestFocusInWindow();
}
});
});

optionPane.addPropertyChangeListener(this);

setSize(new Dimension(320, 160));
setSize(new Dimension(WIDTH, HEIGHT));
setResizable(false);
setLocationRelativeTo(window);
}

@Override
public void propertyChange(PropertyChangeEvent pce) {
public void propertyChange(final PropertyChangeEvent pce) {
String prop = pce.getPropertyName();
boolean source = pce.getSource() == optionPane;
boolean vp = JOptionPane.VALUE_PROPERTY.equals(prop);
Expand All @@ -78,7 +79,7 @@ public void propertyChange(PropertyChangeEvent pce) {
if (value.equals(Const.T_INIC)) {
nickName = tfNickName.getText();
boolean nickOk = nickName.matches(Const.NICK_REGEX);
boolean lnickOk = nickName.length() < 6;
boolean lnickOk = nickName.length() < MAX_NICK_LENGHT;

if (nickOk && lnickOk) {
loadPlayer();
Expand All @@ -102,8 +103,8 @@ private void nickError() {
nickName = null;
tfNickName.requestFocusInWindow();
}
private void unexistentNickError(IPlayerNullObject player) {

private void unexistentNickError(final IPlayerNullObject player) {
tfNickName.selectAll();
JOptionPane.showMessageDialog(
this,
Expand All @@ -113,16 +114,16 @@ private void unexistentNickError(IPlayerNullObject player) {
nickName = null;
tfNickName.requestFocusInWindow();
}

private void closeDialog() {
tfNickName.setText(null);
setVisible(false);
}

private void loadPlayer() {
PlayerFile aj = new PlayerFile();
IPlayerNullObject player;

if (aj.playerExists(nickName)) {
player = new Player();
MementoPlayer jm = aj.open(nickName);
Expand Down
24 changes: 9 additions & 15 deletions src/main/java/edu/patterns/image/FlyweightFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,37 @@
import java.util.HashMap;

public class FlyweightFactory {

private HashMap<String, FlyweightModel> models;

public FlyweightFactory() {
models = new HashMap<>();
}

public FlyweightModel getModel(String type) {

if (models.get(type) != null) {

return models.get(type);

} else {

ArrayList<String> paths = new ArrayList<>();

switch (type) {
case "playerShip":
paths.add("res/nave.png");
paths.add("res/sprites/ship.png");
break;
case "bullet":
paths.add("res/missile.png");
paths.add("res/laser.png");
paths.add("res/sprites/missile.png");
paths.add("res/sprites/laser.png");
break;
case "squid":
paths.add("res/cal0.png");
paths.add("res/cal1.png");
paths.add("res/sprites/squid_0.png");
paths.add("res/sprites/squid_1.png");
break;
case "crab":
paths.add("res/can0.png");
paths.add("res/can1.png");
paths.add("res/sprites/crab_0.png");
paths.add("res/sprites/crab_1.png");
break;
case "octopus":
paths.add("res/pul0.png");
paths.add("res/pul1.png");
paths.add("res/sprites/octopus_0.png");
paths.add("res/sprites/octopus_1.png");
break;
default:
return null;
Expand All @@ -50,5 +45,4 @@ public FlyweightModel getModel(String type) {
return model;
}
}

}
4 changes: 1 addition & 3 deletions src/main/java/edu/patterns/interfaces/IBulletPrototype.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package edu.patterns.interfaces;

public interface IBulletPrototype extends Cloneable {

public IBulletPrototype cloneBullet();

IBulletPrototype cloneBullet();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.patterns.interfaces;

import edu.patterns.model.*;
import edu.patterns.model.Ship;

public interface IEnemyFactoryMethod {
public Ship createEnemy(int type);
Ship createEnemy(int type);
}
4 changes: 1 addition & 3 deletions src/main/java/edu/patterns/interfaces/IPlayerFileProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
import java.util.List;

public interface IPlayerFileProxy {

public List<String[]> getData();

List<String[]> getData();
}
22 changes: 7 additions & 15 deletions src/main/java/edu/patterns/interfaces/IPlayerNullObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@
import edu.patterns.player.MementoPlayer;

public interface IPlayerNullObject {

public boolean isNull();

public String getName();

public String getNickName();

public int getMaxScore();

public void openPlayer(MementoPlayer mementoPlayer);

public MementoPlayer savePlayer();

public void setMaxScore(int maxScore);

boolean isNull();
String getName();
String getNickName();
int getMaxScore();
void openPlayer(MementoPlayer mementoPlayer);
MementoPlayer savePlayer();
void setMaxScore(int maxScore);
}
7 changes: 0 additions & 7 deletions src/main/java/edu/patterns/model/ModelFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ public int getScore() {
return score;
}

/**
* Sets the score of the current game.
* @param score Score value.
*/
public void setScore(int score) {
this.score = score;
}
Expand Down Expand Up @@ -139,9 +135,6 @@ public void enemyShooting() {
enemyShootingAcumulator = 0;
}

/**
*
*/
public void verifyEnemyCollisions() {
List<Entity> bullets = entities.stream()
.filter(x -> x instanceof BulletPrototype)
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/edu/patterns/model/PlayerShipSingleton.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public void draw(Graphics g) {

@Override
public void move(String d) {

switch (d) {
case "D":
if (posX < 440) {
Expand All @@ -49,7 +48,6 @@ public void move(String d) {
break;
default:
}

}

public void hurt() {
Expand Down

0 comments on commit e1c2bb0

Please sign in to comment.