Browse Source
matchfield: refactored Matchfield class structure
matchfield: refactored Matchfield class structure
Lorenz Hohmann
3 years ago
2 changed files with 15 additions and 11 deletions
-
13src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java
-
13src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java
@ -1,20 +1,23 @@ |
|||
package de.tims.fleetstorm.matchfield; |
|||
|
|||
public class MatchfieldCreation { |
|||
public class Matchfield { |
|||
|
|||
private int[][] matchfield; |
|||
private int size; |
|||
|
|||
public MatchfieldCreation(int size) { |
|||
public static final int EMPTY = 0; |
|||
public static final int SHIP = 1; |
|||
public static final int SHOT = 2; |
|||
|
|||
public Matchfield(int size) { |
|||
this.size = size; |
|||
this.matchfield = new int[this.size][this.size]; |
|||
} |
|||
|
|||
public int[][] createMatchfield() { |
|||
this.matchfield = new int[this.size][this.size]; |
|||
|
|||
for (int i = 0; i < size; i++) { |
|||
for (int j = 0; j < size; j++) { |
|||
this.matchfield[i][j] = 1; |
|||
this.matchfield[i][j] = Matchfield.EMPTY; |
|||
} |
|||
} |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue