]> git.mxchange.org Git - shipsimu.git/blobdiff - application/shipsimu/classes/structures/extended/class_BaseCabinStructure.php
Updated 'core' + renamed 'main' -> 'classes'.
[shipsimu.git] / application / shipsimu / classes / structures / extended / class_BaseCabinStructure.php
diff --git a/application/shipsimu/classes/structures/extended/class_BaseCabinStructure.php b/application/shipsimu/classes/structures/extended/class_BaseCabinStructure.php
new file mode 100644 (file)
index 0000000..77a81ae
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+/**
+ * General cabin structure class
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+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
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       // Kabine hinzufuegen
+       public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) {
+               // 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);
+       }
+
+       // Wrapper fuer setDeckInstance->setPartInstance
+       public final function setDeckInstance ($deck) {
+               parent::setPartInstance($deck);
+       }
+
+       // Getter-Methode fuer Anzahl Betten
+       public final function getNumBeds () {
+               return $this->numBeds;
+       }
+
+       // Getter-Methode fuer Anzahl Kabinen
+       public final function getNumCabin () {
+               return $this->numCabin;
+       }
+
+       // Setter-Methode fuer Anzahl Betten
+       public final function setNumBeds ($numBeds) {
+               $this->numBeds = $numBeds;
+       }
+
+       // Setter-Methode fuer Anzahl Raeume
+       public final function setNumRooms ($numRooms) {
+               $this->numRooms = $numRooms;
+       }
+
+       // Setter-Methode fuer Anzahl Kabinen
+       public final function setNumCabin ($numCabin) {
+               $this->numCabin = $numCabin;
+       }
+
+       // Loesch-Methode fuer Anzahl Betten
+       public final function removeNumBeds() {
+               unset($this->numBeds);
+       }
+
+       // Loesch-Methode fuer Anzahl Kabinen
+       public final function removeNumCabin() {
+               unset($this->numCabin);
+       }
+
+       // Loesch-Methode fuer Anzahl Raeume
+       public final function removeNumRooms() {
+               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'))) {
+                       // Get new instance
+                       $cabType = "Kabine ohne Namen";
+                       $cab = $this->getPartInstance();
+                       if (!is_null($cab)) {
+                               // Kabinenbeschreibung holen
+                               $cabType = $cab->__toString();
+                       }
+
+                       // Debug-Meldung ausgeben
+                       $this->debugOutput(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.",
+                               __CLASS__,
+                               __LINE__,
+                               $num,
+                               $cabType,
+                               $beds,
+                               $cabinBeds
+                       ));
+               }
+               return $cabinBeds;
+       }
+}
+
+// [EOF]
+?>