]> git.mxchange.org Git - shipsimu.git/blob - application/ship-simu/main/structures/extended/class_BaseCabinStructure.php
9f80e43511b8a70bebadf3e7fef3c1d5832c04ad
[shipsimu.git] / application / ship-simu / main / structures / extended / class_BaseCabinStructure.php
1 <?php
2 // Kabinen allgemein
3 class BaseCabinStructure extends BaseStructure {
4         // --- Besondere Eigenschaften dazufuegen: ---
5         // Anzahl der Kabinen im Schiff
6         private $numCabin = 0;
7
8         // Anzahl Raeume pro Kabine (kann auch nur 1 sein)
9         private $numRooms = 0;
10
11         // Anzahl Betten, verallgemeinert
12         private $numBeds = 0;
13
14         // Konstruktor
15         private function __construct ($class) {
16                 // Call parent constructor
17                 parent::constructor($class);
18
19                 // Debug message
20                 if (((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
21                         $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
22                                 __CLASS__,
23                                 __LINE__
24                         ));
25                 }
26
27                 // Set description
28                 $this->setPartDescr("Kabinenstruktur");
29         }
30
31         /**
32          * Calls the private constructor
33          *
34          * @param       $class  The class' name
35          * @return      void
36          */
37         public function constructor ($class) {
38                 $this->__construct($class);
39         }
40
41         // Kabine hinzufuegen
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&uuml;r das Schiff <strong>%s</strong> konstruiert.<br />\n",
44                         __CLASS__,
45                         __LINE__,
46                         $cabinInstance->getPartDescr(),
47                         $shipInstance->getShipName()
48                 ));
49
50                 // Eltern-Methode aufrufen
51                 parent::addShipPartToShip ($shipInstance, $cabinInstance);
52
53                 // Restlichen Daten ebenfalls
54                 $this->setNumCabin($cabinInstance->numCabin);
55                 $this->setNumRooms($cabinInstance->numRooms);
56                 $this->setNumBeds($cabinInstance->numBeds);
57
58                 // Unnoetige Attribute entfernen
59                 $cabinInstance->removeNumCabin();
60                 $cabinInstance->removeNumRooms();
61                 $cabinInstance->removeNumBeds();
62
63                 // Instanz setzen
64                 $this->setDeckInstance($cabinInstance);
65
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",
68                         __CLASS__,
69                         __LINE__,
70                         $cabinInstance->getPartDescr(),
71                         $shipInstance->getShipName()
72                 ));
73         }
74
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",
78                         __CLASS__,
79                         __LINE__
80                 ));
81                 parent::setPartInstance($deck);
82         }
83
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",
87                         __CLASS__,
88                         __LINE__,
89                         $this->numBeds
90                 ));
91                 return $this->numBeds;
92         }
93
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",
97                         __CLASS__,
98                         __LINE__,
99                         $this->numCabin
100                 ));
101                 return $this->numCabin;
102         }
103
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",
107                         __CLASS__,
108                         __LINE__,
109                         $numBeds
110                 ));
111                 $this->numBeds = $numBeds;
112         }
113
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&auml;ume gesetzt.<br />\n",
117                         __CLASS__,
118                         __LINE__,
119                         $numRooms
120                 ));
121                 $this->numRooms = $numRooms;
122         }
123
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",
127                         __CLASS__,
128                         __LINE__,
129                         $numCabin
130                 ));
131                 $this->numCabin = $numCabin;
132         }
133
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&ouml;scht.<br />\n",
137                         __CLASS__,
138                         __LINE__
139                 ));
140                 unset($this->numBeds);
141         }
142
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&ouml;scht.<br />\n",
146                         __CLASS__,
147                         __LINE__
148                 ));
149                 unset($this->numCabin);
150         }
151
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&auml;ume gel&ouml;scht.<br />\n",
155                         __CLASS__,
156                         __LINE__
157                 ));
158                 unset($this->numRooms);
159         }
160
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'))) {
168                         // Get new instance
169                         $cabType = "Kabine ohne Namen";
170                         $cab = $this->getPartInstance();
171                         if (!is_null($cab)) {
172                                 // Kabinenbeschreibung holen
173                                 $cabType = $cab->__toString();
174                         }
175
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",
178                                 __CLASS__,
179                                 __LINE__,
180                                 $num,
181                                 $cabType,
182                                 $beds,
183                                 $cabinBeds
184                         ));
185                 }
186                 return $cabinBeds;
187         }
188 }
189
190 // [EOF]
191 ?>