Exemplo n.º 1
0
 public int fireLeft() throws Exception {
   String str = getQuadrantXY(tank.getX(), tank.getY());
   int tankV = Integer.valueOf(str.substring(0, 1));
   int tankH = Integer.valueOf(str.substring(2, str.length()));
   tank.turn(Direction.LEFT);
   for (int idx = tankV; idx < tankV + 1; idx++) {
     for (int j = tankH; j >= 0; j--) {
       if (battleField.scanQuadrant(idx, j) == "B") {
         tank.fire();
       }
     }
   }
   return tankH;
 }
Exemplo n.º 2
0
 public int fireDown() throws Exception {
   String str = getQuadrantXY(tank.getX(), tank.getY());
   int tankV = Integer.valueOf(str.substring(0, 1));
   int tankH = Integer.valueOf(str.substring(2, str.length()));
   tank.turn(Direction.DOWN);
   for (int idx = tankV; idx < battleField.getBattleField().length; idx++) {
     for (int j = tankH; j < tankH + 1; j++) {
       if (battleField.scanQuadrant(idx, j) == "B") {
         tank.fire();
       }
     }
   }
   return tankV;
 }