3 * General cabin structure class
5 * @author Roland Haeder <webmaster@ship-simu.org>
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
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.
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.
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/>.
24 class BaseCabinStructure extends BaseStructure {
25 // --- Besondere Eigenschaften dazufuegen: ---
26 // Anzahl der Kabinen im Schiff
27 private $numCabin = 0;
29 // Anzahl Raeume pro Kabine (kann auch nur 1 sein)
30 private $numRooms = 0;
32 // Anzahl Betten, verallgemeinert
36 protected function __construct ($className) {
37 // Call parent constructor
38 parent::__construct($className);
42 public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) {
43 // Eltern-Methode aufrufen
44 parent::addShipPartToShip ($shipInstance, $cabinInstance);
46 // Restlichen Daten ebenfalls
47 $this->setNumCabin($cabinInstance->numCabin);
48 $this->setNumRooms($cabinInstance->numRooms);
49 $this->setNumBeds($cabinInstance->numBeds);
51 // Unnoetige Attribute entfernen
52 $cabinInstance->removeNumCabin();
53 $cabinInstance->removeNumRooms();
54 $cabinInstance->removeNumBeds();
57 $this->setDeckInstance($cabinInstance);
60 // Wrapper fuer setDeckInstance->setPartInstance
61 public final function setDeckInstance ($deck) {
62 parent::setPartInstance($deck);
65 // Getter-Methode fuer Anzahl Betten
66 public final function getNumBeds () {
67 return $this->numBeds;
70 // Getter-Methode fuer Anzahl Kabinen
71 public final function getNumCabin () {
72 return $this->numCabin;
75 // Setter-Methode fuer Anzahl Betten
76 public final function setNumBeds ($numBeds) {
77 $this->numBeds = $numBeds;
80 // Setter-Methode fuer Anzahl Raeume
81 public final function setNumRooms ($numRooms) {
82 $this->numRooms = $numRooms;
85 // Setter-Methode fuer Anzahl Kabinen
86 public final function setNumCabin ($numCabin) {
87 $this->numCabin = $numCabin;
90 // Loesch-Methode fuer Anzahl Betten
91 public final function removeNumBeds() {
92 unset($this->numBeds);
95 // Loesch-Methode fuer Anzahl Kabinen
96 public final function removeNumCabin() {
97 unset($this->numCabin);
100 // Loesch-Methode fuer Anzahl Raeume
101 public final function removeNumRooms() {
102 unset($this->numRooms);
105 // Bettenanzahl pro Kabine berechnen
106 public function calcTotalBedsByCabin () {
107 // Dann Bettenanzahl holen und aufaddieren
108 $beds = $this->getNumBeds();
109 $num = $this->getNumCabin();
110 $cabinBeds = $beds * $num;
111 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) {
113 $cabType = "Kabine ohne Namen";
114 $cab = $this->getPartInstance();
115 if (!is_null($cab)) {
116 // Kabinenbeschreibung holen
117 $cabType = $cab->__toString();
120 // Debug-Meldung ausgeben
121 $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.",