Debug mailer finished and debug messages removed:
[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 ($className) {
37                 // Call parent constructor
38                 parent::__construct($className);
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->debugOutput(sprintf("[%s:%d] Die Kabine <strong>%s</strong> wird f&uuml;r das Schiff <strong>%s</strong> konstruiert.",
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->debugOutput(sprintf("[%s:%d] Die Kabine <strong>%s</strong> wurde in das Schiff eingebaut.",
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                 parent::setPartInstance($deck);
81         }
82
83         // Getter-Methode fuer Anzahl Betten
84         public final function getNumBeds () {
85                 return $this->numBeds;
86         }
87
88         // Getter-Methode fuer Anzahl Kabinen
89         public final function getNumCabin () {
90                 return $this->numCabin;
91         }
92
93         // Setter-Methode fuer Anzahl Betten
94         public final function setNumBeds ($numBeds) {
95                 $this->numBeds = $numBeds;
96         }
97
98         // Setter-Methode fuer Anzahl Raeume
99         public final function setNumRooms ($numRooms) {
100                 $this->numRooms = $numRooms;
101         }
102
103         // Setter-Methode fuer Anzahl Kabinen
104         public final function setNumCabin ($numCabin) {
105                 $this->numCabin = $numCabin;
106         }
107
108         // Loesch-Methode fuer Anzahl Betten
109         public final function removeNumBeds() {
110                 unset($this->numBeds);
111         }
112
113         // Loesch-Methode fuer Anzahl Kabinen
114         public final function removeNumCabin() {
115                 unset($this->numCabin);
116         }
117
118         // Loesch-Methode fuer Anzahl Raeume
119         public final function removeNumRooms() {
120                 unset($this->numRooms);
121         }
122
123         // Bettenanzahl pro Kabine berechnen
124         public function calcTotalBedsByCabin () {
125                 // Dann Bettenanzahl holen und aufaddieren
126                 $beds = $this->getNumBeds();
127                 $num  = $this->getNumCabin();
128                 $cabinBeds = $beds * $num;
129                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) {
130                         // Get new instance
131                         $cabType = "Kabine ohne Namen";
132                         $cab = $this->getPartInstance();
133                         if (!is_null($cab)) {
134                                 // Kabinenbeschreibung holen
135                                 $cabType = $cab->__toString();
136                         }
137
138                         // Debug-Meldung ausgeben
139                         $this->debugOutput(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.",
140                                 __CLASS__,
141                                 __LINE__,
142                                 $num,
143                                 $cabType,
144                                 $beds,
145                                 $cabinBeds
146                         ));
147                 }
148                 return $cabinBeds;
149         }
150 }
151
152 // [EOF]
153 ?>