public void useReserve() { if (reserves >= 1) { if (tank.isEmpty()) { dead = false; } tank.setFuelLevel(tank.getFuelCapacity()); reserves--; } }
public void move(int distance, Direction direction) { if (!dead) { move(distance, direction, true); if (tank.isEmpty()) { dead = true; notifyPropertyChangeListeners(new PropertyChangeEvent(this, "dead", false, true)); } } }
public void move(int distance, Direction direction, boolean useFuel) { switch (direction) { case UP: location.y -= distance; break; case DOWN: location.y += distance; break; case LEFT: location.x -= distance; break; case RIGHT: location.x += distance; break; default: assert false : "Bad direction: " + location; } if (useFuel) tank.useFuel(1); }
public void refuel(int fuel) { tank.refuel(fuel); if (!tank.isEmpty()) { setDead(false); } }