3 class BaseCabinStructure extends BaseStructure {
4 // --- Besondere Eigenschaften dazufuegen: ---
5 // Anzahl der Kabinen im Schiff
8 // Anzahl Raeume pro Kabine (kann auch nur 1 sein)
11 // Anzahl Betten, verallgemeinert
15 private function __construct ($class) {
16 // Call parent constructor
17 parent::constructor($class);
20 if (((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
21 $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
28 $this->setPartDescr("Kabinenstruktur");
32 * Calls the private constructor
34 * @param $class The class' name
37 public function constructor ($class) {
38 $this->__construct($class);
42 public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) {
43 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",
46 $cabinInstance->getPartDescr(),
47 $shipInstance->getShipName()
50 // Eltern-Methode aufrufen
51 parent::addShipPartToShip ($shipInstance, $cabinInstance);
53 // Restlichen Daten ebenfalls
54 $this->setNumCabin($cabinInstance->numCabin);
55 $this->setNumRooms($cabinInstance->numRooms);
56 $this->setNumBeds($cabinInstance->numBeds);
58 // Unnoetige Attribute entfernen
59 $cabinInstance->removeNumCabin();
60 $cabinInstance->removeNumRooms();
61 $cabinInstance->removeNumBeds();
64 $this->setDeckInstance($cabinInstance);
66 // Einbaut-Meldung ausgeben
67 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",
70 $cabinInstance->getPartDescr(),
71 $shipInstance->getShipName()
75 // Wrapper fuer setDeckInstance->setPartInstance
76 public final function setDeckInstance ($deck) {
77 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Wrapper setDeckInstance->setPartInstance erreicht.<br />\n",
81 parent::setPartInstance($deck);
84 // Getter-Methode fuer Anzahl Betten
85 public final function getNumBeds () {
86 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten angefordert.<br />\n",
91 return $this->numBeds;
94 // Getter-Methode fuer Anzahl Kabinen
95 public final function getNumCabin () {
96 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) angefordert.<br />\n",
101 return $this->numCabin;
104 // Setter-Methode fuer Anzahl Betten
105 public final function setNumBeds ($numBeds) {
106 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten gesetzt.<br />\n",
111 $this->numBeds = $numBeds;
114 // Setter-Methode fuer Anzahl Raeume
115 public final function setNumRooms ($numRooms) {
116 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Raum/Räume gesetzt.<br />\n",
121 $this->numRooms = $numRooms;
124 // Setter-Methode fuer Anzahl Kabinen
125 public final function setNumCabin ($numCabin) {
126 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) gesetzt.<br />\n",
131 $this->numCabin = $numCabin;
134 // Loesch-Methode fuer Anzahl Betten
135 public function removeNumBeds() {
136 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Betten gelöscht.<br />\n",
140 unset($this->numBeds);
143 // Loesch-Methode fuer Anzahl Kabinen
144 public function removeNumCabin() {
145 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Kabinen gelöscht.<br />\n",
149 unset($this->numCabin);
152 // Loesch-Methode fuer Anzahl Raeume
153 public function removeNumRooms() {
154 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Räume gelöscht.<br />\n",
158 unset($this->numRooms);
161 // Bettenanzahl pro Kabine berechnen
162 public function calcTotalBedsByCabin () {
163 // Dann Bettenanzahl holen und aufaddieren
164 $beds = $this->getNumBeds();
165 $num = $this->getNumCabin();
166 $cabinBeds = $beds * $num;
167 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) {
169 $cabType = "Kabine ohne Namen";
170 $cab = $this->getPartInstance();
171 if (!is_null($cab)) {
172 // Kabinenbeschreibung holen
173 $cabType = $cab->__toString();
176 // Debug-Meldung ausgeben
177 $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",