X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=ship-simu%2Fapplication%2Fship-simu%2Fmain%2Fstructures%2Fextended%2Fclass_BaseCabinStructure.php;fp=ship-simu%2Fapplication%2Fship-simu%2Fmain%2Fstructures%2Fextended%2Fclass_BaseCabinStructure.php;h=7d7d7fb8a817b785ff508319eadf14fcb4e6ba8d;hb=85db0cda2cdb5a801db7020aa55b6f4d969f7674;hp=0000000000000000000000000000000000000000;hpb=6f7c99239b34b8ff5e05d719ea24dd213f03f955;p=shipsimu.git 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 index 0000000..7d7d7fb --- /dev/null +++ b/ship-simu/application/ship-simu/main/structures/extended/class_BaseCabinStructure.php @@ -0,0 +1,186 @@ +getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.
\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 %s wird für das Schiff %s konstruiert.
\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 %s wurde in das Schiff eingebaut.
\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.
\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] %d Betten angefordert.
\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] %d Kabine(n) angefordert.
\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] %d Betten gesetzt.
\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] %d Raum/Räume gesetzt.
\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] %d Kabine(n) gesetzt.
\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öscht.
\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öscht.
\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äume gelöscht.
\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 %d Kabinen vom Typ %s zu je %d Betten. Das sind %d Betten.
\n", + __CLASS__, + __LINE__, + $num, + $cabType, + $beds, + $cabinBeds + )); + } + return $cabinBeds; + } +} + +// [EOF] +?>