From f483cdffdaaa42d5df8725e7cad776484ded835d Mon Sep 17 00:00:00 2001 From: Bernardo Sulzbach Date: Mon, 12 Oct 2015 16:54:19 -0300 Subject: [PATCH] World.addLocation() should throw an exception. --- src/main/java/org/dungeon/game/World.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/dungeon/game/World.java b/src/main/java/org/dungeon/game/World.java index cfad894c..53e1b03e 100644 --- a/src/main/java/org/dungeon/game/World.java +++ b/src/main/java/org/dungeon/game/World.java @@ -58,6 +58,9 @@ public Date getWorldDate() { } public void addLocation(Location locationObject, Point coordinates) { + if (locations.containsKey(coordinates)) { + throw new IllegalStateException("tried to repeatedly add a location to " + coordinates + "."); + } locations.put(coordinates, locationObject); worldStatistics.addLocation(locationObject.getName().getSingular()); }