You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
773 B
39 lines
773 B
package de.tims.fleetstorm.matchfield;
|
|
|
|
public class Matchfield {
|
|
|
|
private int[][] matchfield;
|
|
private 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() {
|
|
for (int i = 0; i < size; i++) {
|
|
for (int j = 0; j < size; j++) {
|
|
this.matchfield[i][j] = Matchfield.EMPTY;
|
|
}
|
|
}
|
|
|
|
return this.matchfield;
|
|
}
|
|
|
|
public int getSize() {
|
|
return this.matchfield.length * this.matchfield[0].length;
|
|
}
|
|
|
|
public int getState(int x, int y) {
|
|
return this.matchfield[x][y];
|
|
}
|
|
|
|
public void setState(int x, int y, int state) {
|
|
this.matchfield[x][y] = state;
|
|
}
|
|
|
|
}
|