示例#1
0
 public boolean equipWeapon(Weapon w) {
   if (realSlot == 0) {
     return false;
   } else {
     w.setIsEquipped(true);
     weaponList.add(w);
     realCapacity -= w.getWeight();
     realSlot -= 1;
     return true;
   }
 }
示例#2
0
 public boolean removeWeapon(int n) {
   if (n > weaponList.size() || n == 0) {
     return false;
   } else {
     realCapacity += weaponList.get(n - 1).getWeight();
     Weapon w = weaponList.get(n - 1);
     w.setIsEquipped(false);
     weaponList.remove(n - 1);
     realSlot += 1;
     return true;
   }
 }