package de.eightbitboy.ecorealms.map;

public class Map {
	private int sizeX;
	private int sizeY;
	private MapEntity[] entities;

	public Map(int sizeX, int sizeY) {
		this.sizeX = sizeX;
		this.sizeY = sizeY;
		initialize();
	}


	public int getSizeX() {
		return this.sizeX;
	}

	public int getSizeY() {
		return this.sizeY;
	}

	MapEntity[] getEntities() {
		return this.entities;
	}

	private void initialize() {
		entities = new MapEntity[sizeX * sizeY];
	}

	public void put(MapEntity entity) {
		if (!hasValidPosition(entity)) {
			throw new InvalidMapAccessException(
					"The entity has an invalid position: " + entity.getPosition().toString());
		} else {
			insert(entity);
		}
	}

	private void insert(MapEntity entity) {

	}

	public void remove(MapEntity entity) {
		
	}

	private boolean hasValidPosition(MapEntity entity) {
		MapPoint position = entity.getPosition();

		return !(position.x < 0 ||
				position.y < 0 ||
				position.x >= this.sizeX ||
				position.y >= this.sizeY);
	}

	public MapEntity get(MapPoint position) {
		//TODO
		return new MapEntity() {
			@Override
			public MapPoint getPosition() {
				return null;
			}

			@Override
			public int getSizeX() {
				return 0;
			}

			@Override
			public int getSizeY() {
				return 0;
			}
		};
	}
}

@@ -639,22 +639,11 @@
 on()
-.toString()
 );%0A
+
 %09%09%7D 
@@ -717,17 +717,295 @@
 tity) %7B%0A
+%09%09MapPoint position = entity.getPosition();%0A%09%09if (positionIsFree(position)) %7B%0A%09%09%09int index = (position.x %25 sizeX) + position.y;%0A%09%09%09entities%5Bindex%5D = entity;%0A%09%09%7D else %7B%0A%09%09%09throw new InvalidMapAccessException(%0A%09%09%09%09%09%22The position is already occupied: %22 + entity.getPosition());%0A%09%09%7D
 %0A
-
 %09%7D%0A%0A%09pub
@@ -1044,11 +1044,9 @@
 ) %7B%0A
-%09%09
 %0A
+
 %09%7D%0A%0A
@@ -1223,24 +1223,24 @@
 is.sizeX %7C%7C%0A
-
 %09%09%09%09position
@@ -1258,24 +1258,102 @@
 sizeY);%0A%09%7D%0A%0A
+%09private boolean positionIsFree(MapPoint point) %7B%0A%09%09//TODO%0A%09%09return true;%0A%09%7D%0A%0A
 %09public MapE

Implement logic