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 if (((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
42 $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
49 $this->setObjectDescription("Kabinenstruktur");
53 public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) {
54 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",
57 $cabinInstance->getObjectDescription(),
58 $shipInstance->getShipName()
61 // Eltern-Methode aufrufen
62 parent::addShipPartToShip ($shipInstance, $cabinInstance);
64 // Restlichen Daten ebenfalls
65 $this->setNumCabin($cabinInstance->numCabin);
66 $this->setNumRooms($cabinInstance->numRooms);
67 $this->setNumBeds($cabinInstance->numBeds);
69 // Unnoetige Attribute entfernen
70 $cabinInstance->removeNumCabin();
71 $cabinInstance->removeNumRooms();
72 $cabinInstance->removeNumBeds();
75 $this->setDeckInstance($cabinInstance);
77 // Einbaut-Meldung ausgeben
78 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",
81 $cabinInstance->getObjectDescription(),
82 $shipInstance->getShipName()
86 // Wrapper fuer setDeckInstance->setPartInstance
87 public final function setDeckInstance ($deck) {
88 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Wrapper setDeckInstance->setPartInstance erreicht.<br />\n",
92 parent::setPartInstance($deck);
95 // Getter-Methode fuer Anzahl Betten
96 public final function getNumBeds () {
97 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten angefordert.<br />\n",
102 return $this->numBeds;
105 // Getter-Methode fuer Anzahl Kabinen
106 public final function getNumCabin () {
107 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) angefordert.<br />\n",
112 return $this->numCabin;
115 // Setter-Methode fuer Anzahl Betten
116 public final function setNumBeds ($numBeds) {
117 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten gesetzt.<br />\n",
122 $this->numBeds = $numBeds;
125 // Setter-Methode fuer Anzahl Raeume
126 public final function setNumRooms ($numRooms) {
127 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Raum/Räume gesetzt.<br />\n",
132 $this->numRooms = $numRooms;
135 // Setter-Methode fuer Anzahl Kabinen
136 public final function setNumCabin ($numCabin) {
137 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) gesetzt.<br />\n",
142 $this->numCabin = $numCabin;
145 // Loesch-Methode fuer Anzahl Betten
146 public final function removeNumBeds() {
147 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Betten gelöscht.<br />\n",
151 unset($this->numBeds);
154 // Loesch-Methode fuer Anzahl Kabinen
155 public final function removeNumCabin() {
156 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Kabinen gelöscht.<br />\n",
160 unset($this->numCabin);
163 // Loesch-Methode fuer Anzahl Raeume
164 public final function removeNumRooms() {
165 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Räume gelöscht.<br />\n",
169 unset($this->numRooms);
172 // Bettenanzahl pro Kabine berechnen
173 public function calcTotalBedsByCabin () {
174 // Dann Bettenanzahl holen und aufaddieren
175 $beds = $this->getNumBeds();
176 $num = $this->getNumCabin();
177 $cabinBeds = $beds * $num;
178 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) {
180 $cabType = "Kabine ohne Namen";
181 $cab = $this->getPartInstance();
182 if (!is_null($cab)) {
183 // Kabinenbeschreibung holen
184 $cabType = $cab->__toString();
187 // Debug-Meldung ausgeben
188 $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",