/** * Return a string that identifies the unused capacity of this transporter. * * @return A <code>String</code> meant for a human. */ @Override public String getUnusedString() { return " - " + (getMaxSize() - fighters.size()) + " units"; }
@Override public double getUnused() { return getMaxSize() - fighters.size(); }
/** * Determines if this object can accept the given unit. The unit may not be * of the appropriate type or there may be no room for the unit. * * @param unit * - the <code>Entity</code> to be loaded. * @return <code>true</code> if the unit can be loaded, <code>false</code> * otherwise. */ @Override public boolean canLoad(Entity unit, boolean checkFalse) { // We must have enough space for the new fighter. if(!unit.isEnemyOf(this) && unit.isFighter() && (fighters.size() < getMaxSize())) { return true; } // fighter squadrons can also load other fighter squadrons provided // there is enough space // and the loadee is not empty if ((unit instanceof FighterSquadron) && !unit.isEnemyOf(this) && (getId() != unit.getId()) && (((FighterSquadron) unit).fighters.size() > 0) && ((fighters.size() + ((FighterSquadron) unit).fighters.size()) <= getMaxSize())) { return true; } return false; }