add begin of map class

This commit is contained in:
Sem van der Hoeven
2020-05-15 19:12:56 +02:00
parent 4854902bbf
commit 1958f724d1

View File

@@ -1,4 +1,35 @@
package netwerkprog.game.client;
public class Map {
private char[][] map;
public Map(int size) {
this(size,size);
}
public Map(int width, int height) {
this.map = new char[height][width];
}
public char get(int x, int y) {
return this.map[y][x];
}
/**
* gets the height of this map
* @return -1 if the map is null or is empty, otherwise the height.
*/
public int getHeight() {
return this.map == null || this.map.length == 0 ? -1 : this.map.length;
}
/**
* gets the width of this map
* @return -1 if the map is null or is empty, otherwise the width
*/
public int getWidth() {
return this.map == null || this.map.length == 0 ? -1 : this.map[0].length;
}
}