3 * General cabin structure class
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class BaseCabinStructure extends BaseStructure {
25 // --- Besondere Eigenschaften dazufuegen: ---
26 // Anzahl der Kabinen im Schiff
27 private $numCabin = 0;
29 // Anzahl Raeume pro Kabine (kann auch nur 1 sein)
30 private $numRooms = 0;
32 // Anzahl Betten, verallgemeinert
36 protected function __construct ($class) {
37 // Call parent constructor
38 parent::__construct($class);
41 $this->setObjectDescription("Kabinenstruktur");
45 public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) {
46 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Kabine <strong>%s</strong> wird für das Schiff <strong>%s</strong> konstruiert.<br />\n",
49 $cabinInstance->getObjectDescription(),
50 $shipInstance->getShipName()
53 // Eltern-Methode aufrufen
54 parent::addShipPartToShip ($shipInstance, $cabinInstance);
56 // Restlichen Daten ebenfalls
57 $this->setNumCabin($cabinInstance->numCabin);
58 $this->setNumRooms($cabinInstance->numRooms);
59 $this->setNumBeds($cabinInstance->numBeds);
61 // Unnoetige Attribute entfernen
62 $cabinInstance->removeNumCabin();
63 $cabinInstance->removeNumRooms();
64 $cabinInstance->removeNumBeds();
67 $this->setDeckInstance($cabinInstance);
69 // Einbaut-Meldung ausgeben
70 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",
73 $cabinInstance->getObjectDescription(),
74 $shipInstance->getShipName()
78 // Wrapper fuer setDeckInstance->setPartInstance
79 public final function setDeckInstance ($deck) {
80 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Wrapper setDeckInstance->setPartInstance erreicht.<br />\n",
84 parent::setPartInstance($deck);
87 // Getter-Methode fuer Anzahl Betten
88 public final function getNumBeds () {
89 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten angefordert.<br />\n",
94 return $this->numBeds;
97 // Getter-Methode fuer Anzahl Kabinen
98 public final function getNumCabin () {
99 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) angefordert.<br />\n",
104 return $this->numCabin;
107 // Setter-Methode fuer Anzahl Betten
108 public final function setNumBeds ($numBeds) {
109 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten gesetzt.<br />\n",
114 $this->numBeds = $numBeds;
117 // Setter-Methode fuer Anzahl Raeume
118 public final function setNumRooms ($numRooms) {
119 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Raum/Räume gesetzt.<br />\n",
124 $this->numRooms = $numRooms;
127 // Setter-Methode fuer Anzahl Kabinen
128 public final function setNumCabin ($numCabin) {
129 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) gesetzt.<br />\n",
134 $this->numCabin = $numCabin;
137 // Loesch-Methode fuer Anzahl Betten
138 public final function removeNumBeds() {
139 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Betten gelöscht.<br />\n",
143 unset($this->numBeds);
146 // Loesch-Methode fuer Anzahl Kabinen
147 public final function removeNumCabin() {
148 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Kabinen gelöscht.<br />\n",
152 unset($this->numCabin);
155 // Loesch-Methode fuer Anzahl Raeume
156 public final function removeNumRooms() {
157 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Räume gelöscht.<br />\n",
161 unset($this->numRooms);
164 // Bettenanzahl pro Kabine berechnen
165 public function calcTotalBedsByCabin () {
166 // Dann Bettenanzahl holen und aufaddieren
167 $beds = $this->getNumBeds();
168 $num = $this->getNumCabin();
169 $cabinBeds = $beds * $num;
170 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) {
172 $cabType = "Kabine ohne Namen";
173 $cab = $this->getPartInstance();
174 if (!is_null($cab)) {
175 // Kabinenbeschreibung holen
176 $cabType = $cab->__toString();
179 // Debug-Meldung ausgeben
180 $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",