Пример #1
0
 public boolean removePart(Part p) {
   if ((realCapacity - p.getCapacity()) < 0) {
     return false;
   } else {
     realCapacity = realCapacity - p.getCapacity() + p.getWeight();
   }
   capacity -= p.getCapacity();
   speed -= p.getSpeed();
   hp -= p.getHP();
   realHP -= p.getHP();
   p.setIsEquipped(false);
   String type = p.getType();
   if (type.equals("engine")) engine = null;
   if (type.equals("figurehead")) figurehead = null;
   if (type.equals("hull")) hull = null;
   if (type.equals("sail")) sail = null;
   if (type.equals("stabilizer")) {
     stabilizer = null;
   }
   return true;
 }
Пример #2
0
 public void displayBuyMenu(Part p) throws DataException {
   System.out.println();
   System.out.println("== BattleStations :: Le Part :: Details ==");
   System.out.println("Part: " + p.getName());
   System.out.println();
   System.out.println("Speed: " + p.getSpeed());
   System.out.println("HP: " + p.getHP());
   System.out.println("Capacity: " + p.getCapacity());
   System.out.println("Weight: " + p.getWeight());
   System.out.println("Level Required: " + p.getLvlReq());
   System.out.println();
   System.out.println(
       "Gold: "
           + p.getGoldReq()
           + " | Wood: "
           + p.getWoodReq()
           + " | Ore: "
           + p.getOreReq()
           + " | Prock: "
           + p.getPlasmaRockReq());
   System.out.println();
   System.out.print("[R]eturn to main | [B]uy it > ");
 }
Пример #3
0
 public boolean addPart(Part part) {
   if (part.getWeight() < this.realCapacity) {
     Part p = part;
     String type = p.getType();
     if (type.equals("engine")) engine = p;
     if (type.equals("figurehead")) figurehead = p;
     if (type.equals("hull")) hull = p;
     if (type.equals("sail")) sail = p;
     if (type.equals("stabilizer")) stabilizer = p;
     speed += p.getSpeed();
     if (speed < 0) {
       return false;
     }
     // realHP += p.getHP();
     hp += p.getHP();
     capacity += p.getCapacity();
     realCapacity = realCapacity + p.getCapacity() - p.getWeight();
     p.setIsEquipped(true);
     return true;
   } else {
     return false;
   }
 }