diff --git a/boulder-dash/.idea/checkstyle-idea.xml b/boulder-dash/.idea/checkstyle-idea.xml
index 805be345..6f4e9ba3 100644
--- a/boulder-dash/.idea/checkstyle-idea.xml
+++ b/boulder-dash/.idea/checkstyle-idea.xml
@@ -9,6 +9,7 @@
(bundled)
(bundled)
+ $PROJECT_DIR$/ueb01_checkstyle_config-Homework.xml
$PROJECT_DIR$/ueb01_checkstyle_config.xml
diff --git a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/helpers/LevelSaveHelper.class b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/helpers/LevelSaveHelper.class
index 6d19c1e3..e8ae6c4f 100644
Binary files a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/helpers/LevelSaveHelper.class and b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/helpers/LevelSaveHelper.class differ
diff --git a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/DiamondModel.class b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/DiamondModel.class
index d46f2da3..dc6b354d 100644
Binary files a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/DiamondModel.class and b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/DiamondModel.class differ
diff --git a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/DisplayableElementModel.class b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/DisplayableElementModel.class
index 9bcbeed0..62ac63de 100644
Binary files a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/DisplayableElementModel.class and b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/DisplayableElementModel.class differ
diff --git a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/LevelModel.class b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/LevelModel.class
index 03706119..927c6f41 100644
Binary files a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/LevelModel.class and b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/LevelModel.class differ
diff --git a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/RockfordModel.class b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/RockfordModel.class
index 47403727..9e3c8c66 100644
Binary files a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/RockfordModel.class and b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/models/RockfordModel.class differ
diff --git a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.class b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.class
index 847fc4f7..572c042b 100644
Binary files a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.class and b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.class differ
diff --git a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/GameGroundView.class b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/GameGroundView.class
index f29eeb87..b4c3b5f1 100644
Binary files a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/GameGroundView.class and b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/GameGroundView.class differ
diff --git a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/GroundView.class b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/GroundView.class
index b6f4411e..f14c5fe0 100644
Binary files a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/GroundView.class and b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/GroundView.class differ
diff --git a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/WinLoseView.class b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/WinLoseView.class
index a7cc8c9a..3ce0c933 100644
Binary files a/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/WinLoseView.class and b/boulder-dash/classes/production/Boulder Dash/fr/enssat/BoulderDash/views/WinLoseView.class differ
diff --git a/boulder-dash/src/fr/enssat/BoulderDash/models/DiamondModel.java b/boulder-dash/src/fr/enssat/BoulderDash/models/DiamondModel.java
index ba1dbab5..b23a8312 100644
--- a/boulder-dash/src/fr/enssat/BoulderDash/models/DiamondModel.java
+++ b/boulder-dash/src/fr/enssat/BoulderDash/models/DiamondModel.java
@@ -15,6 +15,8 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
* @since 2015-06-19
*/
public class DiamondModel extends DisplayableElementModel {
+ private static final int SIZ_X_OF_SPRITE = 16;
+ private static final int SIZ_Y_OF_SPRITE = 16;
private static String spriteName;
private static boolean isDestructible;
private static boolean canMove;
@@ -25,8 +27,6 @@ public class DiamondModel extends DisplayableElementModel {
private long previousTime;
private int currentFrame;
- private final int SIZ_X_OF_SPRITE = 16;
- private final int SIZ_Y_OF_SPRITE = 16;
private long speed;
private ArrayList framesDiamond;
diff --git a/boulder-dash/src/fr/enssat/BoulderDash/models/DisplayableElementModel.java b/boulder-dash/src/fr/enssat/BoulderDash/models/DisplayableElementModel.java
index dd0bf8c1..556cb66e 100644
--- a/boulder-dash/src/fr/enssat/BoulderDash/models/DisplayableElementModel.java
+++ b/boulder-dash/src/fr/enssat/BoulderDash/models/DisplayableElementModel.java
@@ -210,15 +210,15 @@ public abstract class DisplayableElementModel {
* @return Sprite object
*/
public BufferedImage loadSprite(String spriteName) {
- BufferedImage sprite = null;
+ BufferedImage loadedSprite = null;
try {
- sprite = ImageIO.read(new File("res/drawable/field/" + spriteName + ".gif"));
+ loadedSprite = ImageIO.read(new File("res/drawable/field/" + spriteName + ".gif"));
} catch (IOException e) {
e.printStackTrace();
}
- this.sprite = sprite;
+ sprite = loadedSprite;
return sprite;
}
diff --git a/boulder-dash/src/fr/enssat/BoulderDash/models/LevelModel.java b/boulder-dash/src/fr/enssat/BoulderDash/models/LevelModel.java
index cbb5415a..2c685075 100644
--- a/boulder-dash/src/fr/enssat/BoulderDash/models/LevelModel.java
+++ b/boulder-dash/src/fr/enssat/BoulderDash/models/LevelModel.java
@@ -31,6 +31,11 @@ import java.util.Observable;
* @since 2015-06-19
*/
public class LevelModel extends Observable implements Runnable {
+ /**
+ * Animation speed
+ */
+ private static final int DELAY = 25;
+
private DisplayableElementModel[][] groundGrid;
private String levelName;
private AudioLoadHelper audioLoadHelper;
@@ -54,11 +59,6 @@ public class LevelModel extends Observable implements Runnable {
*/
private Thread spriteAnimator;
- /**
- * Animation speed
- */
- private final int DELAY = 25;
-
/**
* Class constructor
*
@@ -196,9 +196,9 @@ public class LevelModel extends Observable implements Runnable {
private void playCollisionSound(int posX, int posY) {
String collisionSound = null;
- if (this.getRockford().isCollisionDone() == false) {
+ if (!this.getRockford().isCollisionDone()) {
// Out of bounds?
- if (this.isOutOfBounds(posX, posY) == true) {
+ if (this.isOutOfBounds(posX, posY)) {
collisionSound = "touch";
} else {
DisplayableElementModel nextElement = this.groundGrid[posX][posY];
@@ -246,7 +246,7 @@ public class LevelModel extends Observable implements Runnable {
this.playCollisionSound(posX, posY);
// Check that we are not out of bound...
- if (this.isOutOfBounds(posX, posY) == false) {
+ if (!this.isOutOfBounds(posX, posY)) {
// Create a new empty model in the old pos of Rockford
this.groundGrid[oldX][oldY] = new EmptyModel();
@@ -273,13 +273,8 @@ public class LevelModel extends Observable implements Runnable {
* @param blockValue New value
*/
public void triggerBlockChange(String blockValue) {
- // No block value?
- if(blockValue == null || blockValue.isEmpty()) {
- return;
- }
-
- // Cancel if Rockford is already in model
- if((blockValue.equals("Rockford") || blockValue.equals("rockford")) && this.isRockfordInModel()) {
+ // No block value? or Cancel if Rockford is already in model
+ if((blockValue == null || blockValue.isEmpty()) || ((blockValue.equals("Rockford") || blockValue.equals("rockford")) && this.isRockfordInModel())) {
return;
}
diff --git a/boulder-dash/src/fr/enssat/BoulderDash/models/RockfordModel.java b/boulder-dash/src/fr/enssat/BoulderDash/models/RockfordModel.java
index e958ebf4..f87a0cb7 100644
--- a/boulder-dash/src/fr/enssat/BoulderDash/models/RockfordModel.java
+++ b/boulder-dash/src/fr/enssat/BoulderDash/models/RockfordModel.java
@@ -15,6 +15,11 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
* @since 2015-06-19
*/
public class RockfordModel extends DisplayableElementModel {
+ /**
+ * Defines the size of the sprite
+ * */
+ private static final int SIZ_X_OF_SPRITE = 16;
+ private static final int SIZ_Y_OF_SPRITE = 16;
private static String spriteName;
private static boolean isDestructible;
private static boolean canMove;
@@ -32,12 +37,6 @@ public class RockfordModel extends DisplayableElementModel {
private static ArrayList framesRunningRight;
private static ArrayList framesRunningUpOrDown;
- /**
- * Defines the size of the sprite
- */
- private final int SIZ_X_OF_SPRITE = 16;
- private final int SIZ_Y_OF_SPRITE = 16;
-
/**
* Defines the current speed of the object
*/
diff --git a/boulder-dash/src/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.java b/boulder-dash/src/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.java
index 25645d47..07fccff3 100644
--- a/boulder-dash/src/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.java
+++ b/boulder-dash/src/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.java
@@ -18,15 +18,15 @@ import fr.enssat.BoulderDash.views.LevelEditorView;
* @since 2015-06-22
*/
public class AssetsLevelEditorComponent extends JPanel implements ActionListener {
- private LevelEditorView levelEditorView;
-
/**
* Available choices
*/
- static List choiceList = Arrays.asList(
+ private static List choiceList = Arrays.asList(
"Boulder", "Diamond", "Dirt", "Brick Wall", "Expanding Wall", "Magic Wall", "Steel Wall", "Rockford"
);
+ private LevelEditorView levelEditorView;
+
/**
* Class constructor
*
diff --git a/boulder-dash/src/fr/enssat/BoulderDash/views/GameGroundView.java b/boulder-dash/src/fr/enssat/BoulderDash/views/GameGroundView.java
index 640e7fd2..a9d46367 100644
--- a/boulder-dash/src/fr/enssat/BoulderDash/views/GameGroundView.java
+++ b/boulder-dash/src/fr/enssat/BoulderDash/views/GameGroundView.java
@@ -31,7 +31,7 @@ public class GameGroundView extends GroundView {
this.gameController = gameController;
- this.addKeyListener(new GameKeyController(this.levelModel, this.gameController.getAudioLoadHelper()));
+ this.addKeyListener(new GameKeyController(super.getLevelModel(), this.gameController.getAudioLoadHelper()));
this.setBorder(BorderFactory.createLineBorder(Color.black));
this.setFocusable(true);
diff --git a/boulder-dash/src/fr/enssat/BoulderDash/views/GroundView.java b/boulder-dash/src/fr/enssat/BoulderDash/views/GroundView.java
index 359bbcb4..fbc4c0d4 100644
--- a/boulder-dash/src/fr/enssat/BoulderDash/views/GroundView.java
+++ b/boulder-dash/src/fr/enssat/BoulderDash/views/GroundView.java
@@ -22,7 +22,7 @@ import java.util.Observer;
*
*/
public abstract class GroundView extends JPanel implements Observer {
- protected LevelModel levelModel;
+ private LevelModel levelModel;
/**
* Class constructor
@@ -34,6 +34,10 @@ public abstract class GroundView extends JPanel implements Observer {
this.levelModel.addObserver(this);
}
+ protected LevelModel getLevelModel() {
+ return levelModel;
+ }
+
/**
* Draws the map
*
diff --git a/boulder-dash/src/fr/enssat/BoulderDash/views/WinLoseView.java b/boulder-dash/src/fr/enssat/BoulderDash/views/WinLoseView.java
index b0c85837..c0ac71d1 100644
--- a/boulder-dash/src/fr/enssat/BoulderDash/views/WinLoseView.java
+++ b/boulder-dash/src/fr/enssat/BoulderDash/views/WinLoseView.java
@@ -39,10 +39,11 @@ public class WinLoseView extends JFrame{
private void createLayout() {
JTextArea help = new JTextArea();
help.setEditable(false);
- if(winOrLose.equals("win"))
- help.setText("YOU WIN THE GAME :-)");
- else
- help.setText("YOU LOSE THE GAME :-( TRY AGAIN!");
+ if(winOrLose.equals("win")) {
+ help.setText("YOU WIN THE GAME :-)");
+ } else {
+ help.setText("YOU LOSE THE GAME :-( TRY AGAIN!");
+ }
this.add(help);
}
diff --git a/boulder-dash/ueb01_checkstyle_config-Homework.xml b/boulder-dash/ueb01_checkstyle_config-Homework.xml
new file mode 100644
index 00000000..a24aaf1a
--- /dev/null
+++ b/boulder-dash/ueb01_checkstyle_config-Homework.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+