]> git.mxchange.org Git - shipsimu.git/blobdiff - ship-simu/application/ship-simu/main/structures/extended/class_BaseCabinStructure.php
Initial import of current development status
[shipsimu.git] / ship-simu / application / ship-simu / main / structures / extended / class_BaseCabinStructure.php
diff --git a/ship-simu/application/ship-simu/main/structures/extended/class_BaseCabinStructure.php b/ship-simu/application/ship-simu/main/structures/extended/class_BaseCabinStructure.php
new file mode 100644 (file)
index 0000000..7d7d7fb
--- /dev/null
@@ -0,0 +1,186 @@
+<?php
+// Kabinen allgemein
+class BaseCabinStructure extends BaseStructure {
+       // --- Besondere Eigenschaften dazufuegen: ---
+       // Anzahl der Kabinen im Schiff
+       private $numCabin = 0;
+
+       // Anzahl Raeume pro Kabine (kann auch nur 1 sein)
+       private $numRooms = 0;
+
+       // Anzahl Betten, verallgemeinert
+       private $numBeds = 0;
+
+       // Konstruktor
+       private function __construct ($class) {
+               // Eltern-Konstruktor aufrufen
+               parent::constructor($class);
+
+               // Debug message
+               if (((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
+                       $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
+                               __CLASS__,
+                               __LINE__
+                       ));
+               }
+
+               // Beschreibung setzen
+               $this->setPartDescr("Kabinenstruktur");
+       }
+
+       // Konstruktor aufrufen
+       public function constructor ($class) {
+               $this->__construct($class);
+       }
+
+       // Kabine hinzufuegen
+       public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Kabine <strong>%s</strong> wird f&uuml;r das Schiff <strong>%s</strong> konstruiert.<br />\n",
+                       __CLASS__,
+                       __LINE__,
+                       $cabinInstance->getPartDescr(),
+                       $shipInstance->getShipName()
+               ));
+
+               // Eltern-Methode aufrufen
+               parent::addShipPartToShip ($shipInstance, $cabinInstance);
+
+               // Restlichen Daten ebenfalls
+               $this->setNumCabin($cabinInstance->numCabin);
+               $this->setNumRooms($cabinInstance->numRooms);
+               $this->setNumBeds($cabinInstance->numBeds);
+
+               // Unnoetige Attribute entfernen
+               $cabinInstance->removeNumCabin();
+               $cabinInstance->removeNumRooms();
+               $cabinInstance->removeNumBeds();
+
+               // Instanz setzen
+               $this->setDeckInstance($cabinInstance);
+
+               // Einbaut-Meldung ausgeben
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Kabine <strong>%s</strong> wurde in das Schiff eingebaut.<br />\n",
+                       __CLASS__,
+                       __LINE__,
+                       $cabinInstance->getPartDescr(),
+                       $shipInstance->getShipName()
+               ));
+       }
+
+       // Wrapper fuer setDeckInstance->setPartInstance
+       public function setDeckInstance ($deck) {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Wrapper setDeckInstance->setPartInstance erreicht.<br />\n",
+                       __CLASS__,
+                       __LINE__
+               ));
+               parent::setPartInstance($deck);
+       }
+
+       // Getter-Methode fuer Anzahl Betten
+       public function getNumBeds () {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten angefordert.<br />\n",
+                       __CLASS__,
+                       __LINE__,
+                       $this->numBeds
+               ));
+               return $this->numBeds;
+       }
+
+       // Getter-Methode fuer Anzahl Kabinen
+       public function getNumCabin () {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) angefordert.<br />\n",
+                       __CLASS__,
+                       __LINE__,
+                       $this->numCabin
+               ));
+               return $this->numCabin;
+       }
+
+       // Setter-Methode fuer Anzahl Betten
+       public function setNumBeds ($numBeds) {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten gesetzt.<br />\n",
+                       __CLASS__,
+                       __LINE__,
+                       $numBeds
+               ));
+               $this->numBeds = $numBeds;
+       }
+
+       // Setter-Methode fuer Anzahl Raeume
+       public function setNumRooms ($numRooms) {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Raum/R&auml;ume gesetzt.<br />\n",
+                       __CLASS__,
+                       __LINE__,
+                       $numRooms
+               ));
+               $this->numRooms = $numRooms;
+       }
+
+       // Setter-Methode fuer Anzahl Kabinen
+       public function setNumCabin ($numCabin) {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) gesetzt.<br />\n",
+                       __CLASS__,
+                       __LINE__,
+                       $numCabin
+               ));
+               $this->numCabin = $numCabin;
+       }
+
+       // Loesch-Methode fuer Anzahl Betten
+       public function removeNumBeds() {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Betten gel&ouml;scht.<br />\n",
+                       __CLASS__,
+                       __LINE__
+               ));
+               unset($this->numBeds);
+       }
+
+       // Loesch-Methode fuer Anzahl Kabinen
+       public function removeNumCabin() {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Kabinen gel&ouml;scht.<br />\n",
+                       __CLASS__,
+                       __LINE__
+               ));
+               unset($this->numCabin);
+       }
+
+       // Loesch-Methode fuer Anzahl Raeume
+       public function removeNumRooms() {
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl R&auml;ume gel&ouml;scht.<br />\n",
+                       __CLASS__,
+                       __LINE__
+               ));
+               unset($this->numRooms);
+       }
+
+       // Bettenanzahl pro Kabine berechnen
+       public function calcTotalBedsByCabin () {
+               // Dann Bettenanzahl holen und aufaddieren
+               $beds = $this->getNumBeds();
+               $num  = $this->getNumCabin();
+               $cabinBeds = $beds * $num;
+               if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) {
+                       // Instanz holen
+                       $cabType = "Kabine ohne Namen";
+                       $cab = $this->getPartInstance();
+                       if (!is_null($cab)) {
+                               // Kabinenbeschreibung holen
+                               $cabType = $cab->__toString();
+                       }
+
+                       // Debug-Meldung ausgeben
+                       $this->getDebugInstance()->output(sprintf("[%s:%d] Es exisitieren <strong>%d</strong> Kabinen vom Typ <strong>%s</strong> zu je <strong>%d</strong> Betten. Das sind <strong>%d</strong> Betten.<br />\n",
+                               __CLASS__,
+                               __LINE__,
+                               $num,
+                               $cabType,
+                               $beds,
+                               $cabinBeds
+                       ));
+               }
+               return $cabinBeds;
+       }
+}
+
+// [EOF]
+?>