--- /dev/null
+<?php
+
+class PassengerShip extends BaseShip implements ConstructableShip {
+ // Konstruktor
+ private function __construct () {
+ // Eltern-Kontruktor aufrufen
+ parent::constructor(__CLASS__);
+
+ // Debug message
+ if (((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
+ $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
+ __CLASS__,
+ __LINE__
+ ));
+ }
+
+ // Beschreibung setzen
+ $this->setPartDescr("Passagier-Schiff");
+
+ // Unique-ID erzeugen
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeSystemArray();
+ }
+
+ // Passagier-Schiff erstellen
+ public static function createPassengerShip ($shipName) {
+ // Instanz holen
+ $passInstance = new PassengerShip();
+
+ // Debug message
+ if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
+ $passInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein Passagier-Schiff wird erstellt.<br />\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'))) {
+ // Instanz holen
+ $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 <strong>%d</strong> Betten vom Kabinen-Typ <strong>%s</strong> bereit.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $total,
+ $cabType
+ ));
+ }
+ } else {
+ // Keine Kabine!
+ if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%s</strong> ist keine Kabine.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $el->getPartDescr()
+ ));
+ }
+ }
+
+ if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das <strong>%s</strong> mit dem Namen <strong>%s</strong> hat <strong>%d</strong> Betten.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getPartDescr(),
+ $this->getShipName(),
+ $numBeds
+ ));
+
+ // Anzahl zurueckliefern
+ return $numBeds;
+ }
+
+ /**
+ * Stub!
+ */
+ public function saveObjectToDatabase () {
+ $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
+ $this->__toString(),
+ __FUNCTION__
+ ));
+ }
+
+ /**
+ * Limits this object with an ObjectLimits instance
+ */
+ public function limitObject (ObjectLimits $limitInstance) {
+ ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
+ }
+}
+
+// [EOF]
+?>