getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.
\n",
__CLASS__,
__LINE__
));
}
// Set description
$this->setPartDescr("Passagier-Schiff");
// Generate unique ID number
$this->createUniqueID();
// Clean up a little
$this->removeSystemArray();
}
// Passagier-Schiff erstellen
public static function createPassengerShip ($shipName) {
// Get new instance
$passInstance = new PassengerShip();
// Debug message
if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
$passInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein Passagier-Schiff wird erstellt.
\n",
__CLASS__,
__LINE__
));
}
// Set ship's name
$passInstance->setShipName($shipName);
// Instanz zurueckgeben
return $passInstance;
}
// Anzahl Betten ermitteln
final function calcTotalBeds () {
// Struktur-Array holen
$struct = $this->getStructuresArray();
if (is_null($struct)) {
// Empty structures list!
throw new EmptyStructuresListException($this, self::EXCEPTION_EMPTY_STRUCTURES_ARRAY);
}
// Anzahl Betten auf 0 setzen
$numBeds = 0;
// Alle Strukturen nach Kabinen durchsuchen
for ($idx = $struct->getIterator(); $idx->valid(); $idx->next()) {
// Element holen
$el = $idx->current();
// Ist es eine Kabine?
if ($el->isCabin()) {
// Anzahl Betten ermitteln
$total = $el->calcTotalBedsByCabin();
$numBeds += $total;
// Debug-Meldung ausgeben?
if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
// Get new instance
$cabType = "Kabine ohne Namen";
$cab = $el->getPartInstance();
if (!is_null($cab)) {
// Kabinenbeschreibung holen
$cabType = $cab->getPartDescr();
}
// Debug-Meldung ausgeben
$this->getDebugInstance()->output(sprintf("[%s:%d] Es stehen %d Betten vom Kabinen-Typ %s bereit.
\n",
__CLASS__,
__LINE__,
$total,
$cabType
));
}
} else {
// Keine Kabine!
if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] %s ist keine Kabine.
\n",
__CLASS__,
__LINE__,
$el->getPartDescr()
));
}
}
if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das %s mit dem Namen %s hat %d Betten.
\n",
__CLASS__,
__LINE__,
$this->getPartDescr(),
$this->getShipName(),
$numBeds
));
// Anzahl zurueckliefern
return $numBeds;
}
/**
* Stub!
*/
public function saveObjectToDatabase () {
$this->getDebugInstance()->output(sprintf("[%s:] Stub %s erreicht.",
$this->__toString(),
__FUNCTION__
));
}
/**
* Limits this object with an ObjectLimits instance
*/
public function limitObject (ObjectLimits $limitInstance) {
ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
}
}
// [EOF]
?>