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());
		}


	}

	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;
			}
		};
	}
}

@@ -568,16 +568,22 @@
 ception(
+%0A%09%09%09%09%09
 %22The ent
@@ -612,22 +612,17 @@
 ition: %22
-%0A%09%09%09%09%09
+ 
 + entity
@@ -652,17 +652,91 @@
 ());%0A%09%09%7D
-%0A
+ else %7B%0A%09%09%09insert(entity);%0A%09%09%7D%0A%09%7D%0A%0A%09private void insert(MapEntity entity) %7B
 %0A%0A%09%7D%0A%0A%09p

Prepare insert method