ShipPool: rename ancestor->parent, make private
authorAdam Megacz <adam@megacz.com>
Mon, 27 Jul 2009 03:23:02 +0000 (20:23 -0700)
committerAdam Megacz <adam@megacz.com>
Mon, 27 Jul 2009 03:23:02 +0000 (20:23 -0700)
src/edu/berkeley/fleet/loops/ShipPool.java

index 82a5296..f120139 100644 (file)
@@ -11,15 +11,15 @@ import static edu.berkeley.fleet.util.BitManipulations.*;
 public class ShipPool implements Iterable<Ship> {
 
     public final Fleet fleet;
-    public final ShipPool ancestor;
+    private ShipPool parent;
 
     private HashSet<Ship> allocatedShips = new HashSet<Ship>();
 
     public ShipPool(Fleet fleet) { this(fleet, null); }
-    public ShipPool(ShipPool ancestor) { this(ancestor.fleet, ancestor); }
-    public ShipPool(Fleet fleet, ShipPool ancestor) {
+    public ShipPool(ShipPool parent) { this(parent.fleet, parent); }
+    public ShipPool(Fleet fleet, ShipPool parent) {
         this.fleet = fleet;
-        this.ancestor = ancestor;
+        this.parent = parent;
     }
 
     public Iterator<Ship> iterator() { return allocatedShips.iterator(); }
@@ -35,8 +35,8 @@ public class ShipPool implements Iterable<Ship> {
     /** allocate a ship */
     public Ship allocateShip(String type) {
         Ship ship = null;
-        if (ancestor != null) {
-            ship = ancestor.allocateShip(type);
+        if (parent != null) {
+            ship = parent.allocateShip(type);
         } else {
             for(int i=0; ; i++) {
                 ship = fleet.getShip(type, i);
@@ -54,7 +54,7 @@ public class ShipPool implements Iterable<Ship> {
         if (!allocatedShips.contains(ship))
             throw new RuntimeException("ship " + ship + " released but was not allocated");
         allocatedShips.remove(ship);
-        if (ancestor != null) ancestor.releaseShip(ship);
+        if (parent != null) parent.releaseShip(ship);
     }
 
     public void releaseAll() {