Constructor and Description |
---|
ListGrid(int width,
int height)
Initializes an empty grid
|
ListGrid(int width,
int height,
K tile)
Initializes a grid filled with standard tiles.
|
Modifier and Type | Method and Description |
---|---|
K |
getElement(int x,
int y)
Gets the element in a given x and y coordinate
|
int |
getHeight()
Gets height of the grid
|
int |
getWidth()
Gets the width of the grid
|
void |
setElement(int x,
int y,
K element)
Places the element on the given x and y coordinate
|
java.lang.String |
toString() |
public ListGrid(int width, int height)
width
- The width of the gridheight
- The height of the gridpublic ListGrid(int width, int height, K tile)
height
- sets the height of the gridwidth
- sets the width of the gridtile
- gives the TileType the grid is to be filled withpublic int getWidth()
Grid
public int getHeight()
Grid
public K getElement(int x, int y) throws java.lang.IllegalArgumentException
Grid
getElement
in interface Grid<K>
x
- Coordinate in the gridy
- Coordinate in the gridjava.lang.IllegalArgumentException
- Throws an exception if the coordinates are outside of the gridpublic void setElement(int x, int y, K element) throws java.lang.IllegalArgumentException
Grid
setElement
in interface Grid<K>
x
- Coordinate in the gridy
- Coordinate in the gridelement
- The element to place in the gridjava.lang.IllegalArgumentException
public java.lang.String toString()
toString
in class java.lang.Object