Translations to english and debug messages removed (missing files added)
[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                 // Set description
41                 $this->setObjectDescription("Kabinenstruktur");
42         }
43
44         // Kabine hinzufuegen
45         public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) {
46                 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",
47                         __CLASS__,
48                         __LINE__,
49                         $cabinInstance->getObjectDescription(),
50                         $shipInstance->getShipName()
51                 ));
52
53                 // Eltern-Methode aufrufen
54                 parent::addShipPartToShip ($shipInstance, $cabinInstance);
55
56                 // Restlichen Daten ebenfalls
57                 $this->setNumCabin($cabinInstance->numCabin);
58                 $this->setNumRooms($cabinInstance->numRooms);
59                 $this->setNumBeds($cabinInstance->numBeds);
60
61                 // Unnoetige Attribute entfernen
62                 $cabinInstance->removeNumCabin();
63                 $cabinInstance->removeNumRooms();
64                 $cabinInstance->removeNumBeds();
65
66                 // Instanz setzen
67                 $this->setDeckInstance($cabinInstance);
68
69                 // Einbaut-Meldung ausgeben
70                 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",
71                         __CLASS__,
72                         __LINE__,
73                         $cabinInstance->getObjectDescription(),
74                         $shipInstance->getShipName()
75                 ));
76         }
77
78         // Wrapper fuer setDeckInstance->setPartInstance
79         public final function setDeckInstance ($deck) {
80                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Wrapper setDeckInstance->setPartInstance erreicht.<br />\n",
81                         __CLASS__,
82                         __LINE__
83                 ));
84                 parent::setPartInstance($deck);
85         }
86
87         // Getter-Methode fuer Anzahl Betten
88         public final function getNumBeds () {
89                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten angefordert.<br />\n",
90                         __CLASS__,
91                         __LINE__,
92                         $this->numBeds
93                 ));
94                 return $this->numBeds;
95         }
96
97         // Getter-Methode fuer Anzahl Kabinen
98         public final function getNumCabin () {
99                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) angefordert.<br />\n",
100                         __CLASS__,
101                         __LINE__,
102                         $this->numCabin
103                 ));
104                 return $this->numCabin;
105         }
106
107         // Setter-Methode fuer Anzahl Betten
108         public final function setNumBeds ($numBeds) {
109                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Betten gesetzt.<br />\n",
110                         __CLASS__,
111                         __LINE__,
112                         $numBeds
113                 ));
114                 $this->numBeds = $numBeds;
115         }
116
117         // Setter-Methode fuer Anzahl Raeume
118         public final function setNumRooms ($numRooms) {
119                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Raum/R&auml;ume gesetzt.<br />\n",
120                         __CLASS__,
121                         __LINE__,
122                         $numRooms
123                 ));
124                 $this->numRooms = $numRooms;
125         }
126
127         // Setter-Methode fuer Anzahl Kabinen
128         public final function setNumCabin ($numCabin) {
129                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Kabine(n) gesetzt.<br />\n",
130                         __CLASS__,
131                         __LINE__,
132                         $numCabin
133                 ));
134                 $this->numCabin = $numCabin;
135         }
136
137         // Loesch-Methode fuer Anzahl Betten
138         public final function removeNumBeds() {
139                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Betten gel&ouml;scht.<br />\n",
140                         __CLASS__,
141                         __LINE__
142                 ));
143                 unset($this->numBeds);
144         }
145
146         // Loesch-Methode fuer Anzahl Kabinen
147         public final function removeNumCabin() {
148                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Kabinen gel&ouml;scht.<br />\n",
149                         __CLASS__,
150                         __LINE__
151                 ));
152                 unset($this->numCabin);
153         }
154
155         // Loesch-Methode fuer Anzahl Raeume
156         public final function removeNumRooms() {
157                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl R&auml;ume gel&ouml;scht.<br />\n",
158                         __CLASS__,
159                         __LINE__
160                 ));
161                 unset($this->numRooms);
162         }
163
164         // Bettenanzahl pro Kabine berechnen
165         public function calcTotalBedsByCabin () {
166                 // Dann Bettenanzahl holen und aufaddieren
167                 $beds = $this->getNumBeds();
168                 $num  = $this->getNumCabin();
169                 $cabinBeds = $beds * $num;
170                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) {
171                         // Get new instance
172                         $cabType = "Kabine ohne Namen";
173                         $cab = $this->getPartInstance();
174                         if (!is_null($cab)) {
175                                 // Kabinenbeschreibung holen
176                                 $cabType = $cab->__toString();
177                         }
178
179                         // Debug-Meldung ausgeben
180                         $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",
181                                 __CLASS__,
182                                 __LINE__,
183                                 $num,
184                                 $cabType,
185                                 $beds,
186                                 $cabinBeds
187                         ));
188                 }
189                 return $cabinBeds;
190         }
191 }
192
193 // [EOF]
194 ?>