Ejemplo n.º 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;
 }
Ejemplo n.º 2
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;
   }
 }