Пример #1
0
 public void useReserve() {
   if (reserves >= 1) {
     if (tank.isEmpty()) {
       dead = false;
     }
     tank.setFuelLevel(tank.getFuelCapacity());
     reserves--;
   }
 }
Пример #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));
     }
   }
 }
Пример #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);
 }
Пример #4
0
 public void refuel(int fuel) {
   tank.refuel(fuel);
   if (!tank.isEmpty()) {
     setDead(false);
   }
 }