add getConstant(String) methods to FleetTwoFleet implementations
authormegacz <adam@megacz.com>
Sat, 14 Mar 2009 23:52:04 +0000 (16:52 -0700)
committermegacz <adam@megacz.com>
Sat, 14 Mar 2009 23:52:04 +0000 (16:52 -0700)
src/edu/berkeley/fleet/two/FleetTwoDock.java
src/edu/berkeley/fleet/two/FleetTwoShip.java
src/edu/berkeley/fleet/two/ShipDescription.java

index 2868768..e4b3148 100644 (file)
@@ -20,5 +20,11 @@ public abstract class FleetTwoDock extends Dock {
 
     public boolean isOutputDock() { return !dockDescription.isInputDock(); }
 
+    public BitVector getConstant(String constantName) {
+        BitVector bv = dockDescription.getConstant(constantName);
+        if (bv==null)
+            throw new RuntimeException("unknown constant \""+constantName+"\" on dock " + this);
+        return bv;
+    }
 
 }            
index 5a89616..d8d008e 100644 (file)
@@ -30,4 +30,11 @@ public abstract class FleetTwoShip extends Ship {
         }
         throw new RuntimeException("inconsistency: Ship does not belong to its own Fleet!");
     }
+
+    public BitVector getConstant(String constantName) {
+        BitVector bv = shipDescription.getConstant(constantName);
+        if (bv==null)
+            throw new RuntimeException("unknown constant \""+constantName+"\" on ship " + this);
+        return bv;
+    }
 }
index 182eed7..6752e70 100644 (file)
@@ -51,8 +51,7 @@ public class ShipDescription implements Iterable<DockDescription> {
 
     public BitVector getConstant(String name) {
         BitVector c = constants.get(name);
-        if (c==null)
-            throw new RuntimeException("unknown constant " + name);
+        if (c==null) throw new RuntimeException("unknown constant " + name);
         return c;
     }