fix demos to work with new assertAllocated() lines in writeMem
[fleet.git] / src / edu / berkeley / fleet / loops / ShipPool.java
index 1d35e1d..60bd121 100644 (file)
@@ -26,7 +26,7 @@ public class ShipPool implements Iterable<Ship> {
 
     public void allocateShip(Ship ship) {
         if (allocatedShips.contains(ship))
-            throw new RuntimeException("already allocated!");
+            throw new RuntimeException("ship " + ship + " is already allocated!");
         if (parent != null)
             parent.allocateShip(ship);
         allocatedShips.add(ship);
@@ -76,4 +76,11 @@ public class ShipPool implements Iterable<Ship> {
         }
         this.parent = parent;
     }
+
+    public void assertAllocated(Ship ship) {
+        if (allocatedShips.contains(ship)) return;
+        if (parent==null) throw new RuntimeException("assertAllocated() failed");
+        parent.assertAllocated(ship);
+    }
+
 }