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 // Eltern-Konstruktor aufrufen
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",
27 // Beschreibung setzen
28 $this->setPartDescr("Kabinenstruktur");
31 // Konstruktor aufrufen
32 public function constructor ($class) {
33 $this->__construct($class);
37 public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) {
38 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",
41 $cabinInstance->getPartDescr(),
42 $shipInstance->getShipName()
45 // Eltern-Methode aufrufen
46 parent::addShipPartToShip ($shipInstance, $cabinInstance);
48 // Restlichen Daten ebenfalls
49 $this->setNumCabin($cabinInstance->numCabin);
50 $this->setNumRooms($cabinInstance->numRooms);
51 $this->setNumBeds($cabinInstance->numBeds);
53 // Unnoetige Attribute entfernen
54 $cabinInstance->removeNumCabin();
55 $cabinInstance->removeNumRooms();
56 $cabinInstance->removeNumBeds();
59 $this->setDeckInstance($cabinInstance);
61 // Einbaut-Meldung ausgeben
62 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",
65 $cabinInstance->getPartDescr(),
66 $shipInstance->getShipName()
70 // Wrapper fuer setDeckInstance->setPartInstance
71 public function setDeckInstance ($deck) {
72 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Wrapper setDeckInstance->setPartInstance erreicht.<br />\n",
76 parent::setPartInstance($deck);
79 // Getter-Methode fuer Anzahl Betten
80 public function getNumBeds () {
81 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten angefordert.<br />\n",
86 return $this->numBeds;
89 // Getter-Methode fuer Anzahl Kabinen
90 public function getNumCabin () {
91 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) angefordert.<br />\n",
96 return $this->numCabin;
99 // Setter-Methode fuer Anzahl Betten
100 public function setNumBeds ($numBeds) {
101 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten gesetzt.<br />\n",
106 $this->numBeds = $numBeds;
109 // Setter-Methode fuer Anzahl Raeume
110 public function setNumRooms ($numRooms) {
111 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Raum/Räume gesetzt.<br />\n",
116 $this->numRooms = $numRooms;
119 // Setter-Methode fuer Anzahl Kabinen
120 public function setNumCabin ($numCabin) {
121 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) gesetzt.<br />\n",
126 $this->numCabin = $numCabin;
129 // Loesch-Methode fuer Anzahl Betten
130 public function removeNumBeds() {
131 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Betten gelöscht.<br />\n",
135 unset($this->numBeds);
138 // Loesch-Methode fuer Anzahl Kabinen
139 public function removeNumCabin() {
140 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Kabinen gelöscht.<br />\n",
144 unset($this->numCabin);
147 // Loesch-Methode fuer Anzahl Raeume
148 public function removeNumRooms() {
149 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Räume gelöscht.<br />\n",
153 unset($this->numRooms);
156 // Bettenanzahl pro Kabine berechnen
157 public function calcTotalBedsByCabin () {
158 // Dann Bettenanzahl holen und aufaddieren
159 $beds = $this->getNumBeds();
160 $num = $this->getNumCabin();
161 $cabinBeds = $beds * $num;
162 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) {
164 $cabType = "Kabine ohne Namen";
165 $cab = $this->getPartInstance();
166 if (!is_null($cab)) {
167 // Kabinenbeschreibung holen
168 $cabType = $cab->__toString();
171 // Debug-Meldung ausgeben
172 $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",