3 * A passenger ship with one or more decks, cabins, bridge (replacement for the
4 * captain) and many more
6 * @author Roland Haeder <webmaster@ship-simu.org>
8 * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
9 * @license GNU GPL 3.0 or any newer version
10 * @link http://www.ship-simu.org
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class PassengerShip extends BaseShip implements ConstructableShip {
27 protected function __construct () {
28 // Eltern-Kontruktor aufrufen
29 parent::__construct(__CLASS__);
32 $this->removeSystemArray();
33 $this->removeNumberFormaters();
36 // Passagier-Schiff erstellen
37 public final static function createPassengerShip ($shipName) {
39 $passInstance = new PassengerShip();
42 $passInstance->setShipName($shipName);
44 // Instanz zurueckgeben
48 // Anzahl Betten ermitteln
49 public final function calcTotalBeds () {
50 // Struktur-Array holen
51 $struct = $this->getStructuresArray();
53 if (is_null($struct)) {
54 // Empty structures list!
55 throw new EmptyStructuresListException($this, self::EXCEPTION_EMPTY_STRUCTURES_ARRAY);
58 // Anzahl Betten auf 0 setzen
61 // Alle Strukturen nach Kabinen durchsuchen
62 for ($idx = $struct->getIterator(); $idx->valid(); $idx->next()) {
64 $el = $idx->current();
66 // Ist es eine Kabine?
68 // Anzahl Betten ermitteln
69 $total = $el->calcTotalBedsByCabin();
72 // Debug-Meldung ausgeben?
73 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
75 $cabType = "Kabine ohne Namen";
76 $cab = $el->getPartInstance();
78 // Kabinenbeschreibung holen
79 $cabType = $cab->getObjectDescription();
85 // Anzahl zurueckliefern