From 0b1b44e5aa0fa464741527994ef91a1b84077b39 Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Sun, 26 Jul 2009 20:23:02 -0700 Subject: [PATCH] ShipPool: rename ancestor->parent, make private --- src/edu/berkeley/fleet/loops/ShipPool.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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() { -- 1.7.10.4