Esempio n. 1
0
 public void useReserve() {
   if (reserves >= 1) {
     if (tank.isEmpty()) {
       dead = false;
     }
     tank.setFuelLevel(tank.getFuelCapacity());
     reserves--;
   }
 }
Esempio n. 2
0
 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));
     }
   }
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 public void refuel(int fuel) {
   tank.refuel(fuel);
   if (!tank.isEmpty()) {
     setDead(false);
   }
 }