]> git.mxchange.org Git - shipsimu.git/blob - application/ship-simu/main/structures/extended/class_BaseCabinStructure.php
Method constructor() removed, several small fixes
[shipsimu.git] / application / ship-simu / main / structures / extended / class_BaseCabinStructure.php
1 <?php
2 /**
3  * General cabin structure class
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
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
10  *
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.
15  *
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.
20  *
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/>.
23  */
24 class BaseCabinStructure extends BaseStructure {
25         // --- Besondere Eigenschaften dazufuegen: ---
26         // Anzahl der Kabinen im Schiff
27         private $numCabin = 0;
28
29         // Anzahl Raeume pro Kabine (kann auch nur 1 sein)
30         private $numRooms = 0;
31
32         // Anzahl Betten, verallgemeinert
33         private $numBeds = 0;
34
35         // Konstruktor
36         protected function __construct ($class) {
37                 // Call parent constructor
38                 parent::__construct($class);
39
40                 // Debug message
41                 if (((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
42                         $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
43                                 __CLASS__,
44                                 __LINE__
45                         ));
46                 }
47
48                 // Set description
49                 $this->setObjectDescription("Kabinenstruktur");
50         }
51
52         // Kabine hinzufuegen
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&uuml;r das Schiff <strong>%s</strong> konstruiert.<br />\n",
55                         __CLASS__,
56                         __LINE__,
57                         $cabinInstance->getObjectDescription(),
58                         $shipInstance->getShipName()
59                 ));
60
61                 // Eltern-Methode aufrufen
62                 parent::addShipPartToShip ($shipInstance, $cabinInstance);
63
64                 // Restlichen Daten ebenfalls
65                 $this->setNumCabin($cabinInstance->numCabin);
66                 $this->setNumRooms($cabinInstance->numRooms);
67                 $this->setNumBeds($cabinInstance->numBeds);
68
69                 // Unnoetige Attribute entfernen
70                 $cabinInstance->removeNumCabin();
71                 $cabinInstance->removeNumRooms();
72                 $cabinInstance->removeNumBeds();
73
74                 // Instanz setzen
75                 $this->setDeckInstance($cabinInstance);
76
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",
79                         __CLASS__,
80                         __LINE__,
81                         $cabinInstance->getObjectDescription(),
82                         $shipInstance->getShipName()
83                 ));
84         }
85
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",
89                         __CLASS__,
90                         __LINE__
91                 ));
92                 parent::setPartInstance($deck);
93         }
94
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",
98                         __CLASS__,
99                         __LINE__,
100                         $this->numBeds
101                 ));
102                 return $this->numBeds;
103         }
104
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",
108                         __CLASS__,
109                         __LINE__,
110                         $this->numCabin
111                 ));
112                 return $this->numCabin;
113         }
114
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",
118                         __CLASS__,
119                         __LINE__,
120                         $numBeds
121                 ));
122                 $this->numBeds = $numBeds;
123         }
124
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&auml;ume gesetzt.<br />\n",
128                         __CLASS__,
129                         __LINE__,
130                         $numRooms
131                 ));
132                 $this->numRooms = $numRooms;
133         }
134
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",
138                         __CLASS__,
139                         __LINE__,
140                         $numCabin
141                 ));
142                 $this->numCabin = $numCabin;
143         }
144
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&ouml;scht.<br />\n",
148                         __CLASS__,
149                         __LINE__
150                 ));
151                 unset($this->numBeds);
152         }
153
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&ouml;scht.<br />\n",
157                         __CLASS__,
158                         __LINE__
159                 ));
160                 unset($this->numCabin);
161         }
162
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&auml;ume gel&ouml;scht.<br />\n",
166                         __CLASS__,
167                         __LINE__
168                 ));
169                 unset($this->numRooms);
170         }
171
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'))) {
179                         // Get new instance
180                         $cabType = "Kabine ohne Namen";
181                         $cab = $this->getPartInstance();
182                         if (!is_null($cab)) {
183                                 // Kabinenbeschreibung holen
184                                 $cabType = $cab->__toString();
185                         }
186
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",
189                                 __CLASS__,
190                                 __LINE__,
191                                 $num,
192                                 $cabType,
193                                 $beds,
194                                 $cabinBeds
195                         ));
196                 }
197                 return $cabinBeds;
198         }
199 }
200
201 // [EOF]
202 ?>