3 class PassengerShip extends BaseShip implements ConstructableShip, LimitableObject {
5 private function __construct () {
6 // Eltern-Kontruktor aufrufen
7 parent::constructor(__CLASS__);
10 if (((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
11 $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
18 $this->setPartDescr("Passagier-Schiff");
20 // Generate unique ID number
21 $this->createUniqueID();
24 $this->removeSystemArray();
27 // Passagier-Schiff erstellen
28 public static function createPassengerShip ($shipName) {
30 $passInstance = new PassengerShip();
33 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
34 $passInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein Passagier-Schiff wird erstellt.<br />\n",
41 $passInstance->setShipName($shipName);
43 // Instanz zurueckgeben
47 // Anzahl Betten ermitteln
48 final function calcTotalBeds () {
49 // Struktur-Array holen
50 $struct = $this->getStructuresArray();
52 if (is_null($struct)) {
53 // Empty structures list!
54 throw new EmptyStructuresListException($this, self::EXCEPTION_EMPTY_STRUCTURES_ARRAY);
57 // Anzahl Betten auf 0 setzen
60 // Alle Strukturen nach Kabinen durchsuchen
61 for ($idx = $struct->getIterator(); $idx->valid(); $idx->next()) {
63 $el = $idx->current();
65 // Ist es eine Kabine?
67 // Anzahl Betten ermitteln
68 $total = $el->calcTotalBedsByCabin();
71 // Debug-Meldung ausgeben?
72 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
74 $cabType = "Kabine ohne Namen";
75 $cab = $el->getPartInstance();
77 // Kabinenbeschreibung holen
78 $cabType = $cab->getPartDescr();
81 // Debug-Meldung ausgeben
82 $this->getDebugInstance()->output(sprintf("[%s:%d] Es stehen <strong>%d</strong> Betten vom Kabinen-Typ <strong>%s</strong> bereit.<br />\n",
91 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%s</strong> ist keine Kabine.<br />\n",
99 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",
102 $this->getPartDescr(),
103 $this->getShipName(),
107 // Anzahl zurueckliefern
114 public function saveObjectToDatabase () {
115 $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
122 * Limits this object with an ObjectLimits instance
124 public function limitObject (ObjectLimits $limitInstance) {
125 ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");