X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Ffleet%2Floops%2FShipPool.java;h=f120139c74671e9036d97ff27e706d84dfd73e09;hb=0b1b44e5aa0fa464741527994ef91a1b84077b39;hp=82a5296c73b19f4e67692f0cd6f01a2fcd8d7a09;hpb=28d9d71aa61173e668d0bae083bf39d04204d4c8;p=fleet.git diff --git a/src/edu/berkeley/fleet/loops/ShipPool.java b/src/edu/berkeley/fleet/loops/ShipPool.java index 82a5296..f120139 100644 --- a/src/edu/berkeley/fleet/loops/ShipPool.java +++ b/src/edu/berkeley/fleet/loops/ShipPool.java @@ -11,15 +11,15 @@ import static edu.berkeley.fleet.util.BitManipulations.*; public class ShipPool implements Iterable { public final Fleet fleet; - public final ShipPool ancestor; + private ShipPool parent; private HashSet allocatedShips = new HashSet(); 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 iterator() { return allocatedShips.iterator(); } @@ -35,8 +35,8 @@ public class ShipPool implements Iterable { /** 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 { 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() {