Archived
1
0

-Created and implemented ObjectReferenceOutdated Exception

Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
Tony Grosinger 2011-09-15 15:58:18 -07:00
parent b2bd321784
commit efdf505f3e
4 changed files with 18 additions and 11 deletions

View File

@ -1,24 +1,22 @@
package net.grosinger.nomads;
import net.grosinger.nomads.exceptions.ObjectReferenceOutdated;
/**
* A representation of a TownHall. Allows Drones to interact with this building.
*/
public class TownHall extends NeighborBuilding {
// TODO - Rewrite class to make more accessible to Drones
public TownHall(int x, int y, String name, Building building, DroneListItem drone) {
super(x, y, name, building, drone);
}
/**
* Will sell all items in inventory that are able to be sold to the Town
* Hall.
* Will deposit all money piles and turn in all Objectives to Town Hall.
*
* @param inventory
* @param team
* @throws ObjectReferenceOutdated
*/
public void cashInventory() {
public void cashInventory() throws ObjectReferenceOutdated {
if (verifyObjectValidity()) {
Inventory inventory = drone.getInventory();
DroneTeam team = drone.getTeam();
@ -35,7 +33,7 @@ public class TownHall extends NeighborBuilding {
inventory.remove(currentObject);
}
} else {
// Object not valid, do Nothing
throw new ObjectReferenceOutdated();
}
}
@ -44,13 +42,14 @@ public class TownHall extends NeighborBuilding {
*
* @return <code>Point</code> Will return null if the NeighborBuilding was
* created in a previous turn.
*
* @throws ObjectReferenceOutdated
*/
public Point requestNewObjective() {
public Point requestNewObjective() throws ObjectReferenceOutdated {
if (verifyObjectValidity()) {
return Nomads.awesomeWorld.generateObjective(drone);
} else {
// Object not valid, do nothing
return null;
throw new ObjectReferenceOutdated();
}
}
}

View File

@ -0,0 +1,8 @@
package net.grosinger.nomads.exceptions;
public class ObjectReferenceOutdated extends Exception {
public ObjectReferenceOutdated() {
super("This object was created in a previous turn and is no longer valid");
}
}