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, LimitableObject {
27 protected function __construct () {
28 // Eltern-Kontruktor aufrufen
29 parent::__construct(__CLASS__);
32 if (((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
33 $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
40 $this->setObjectDescription("Passagier-Schiff");
42 // Generate unique ID number
43 $this->createUniqueID();
46 $this->removeSystemArray();
49 // Passagier-Schiff erstellen
50 public final static function createPassengerShip ($shipName) {
52 $passInstance = new PassengerShip();
55 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
56 $passInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein Passagier-Schiff wird erstellt.<br />\n",
63 $passInstance->setShipName($shipName);
65 // Instanz zurueckgeben
69 // Anzahl Betten ermitteln
70 final function calcTotalBeds () {
71 // Struktur-Array holen
72 $struct = $this->getStructuresArray();
74 if (is_null($struct)) {
75 // Empty structures list!
76 throw new EmptyStructuresListException($this, self::EXCEPTION_EMPTY_STRUCTURES_ARRAY);
79 // Anzahl Betten auf 0 setzen
82 // Alle Strukturen nach Kabinen durchsuchen
83 for ($idx = $struct->getIterator(); $idx->valid(); $idx->next()) {
85 $el = $idx->current();
87 // Ist es eine Kabine?
89 // Anzahl Betten ermitteln
90 $total = $el->calcTotalBedsByCabin();
93 // Debug-Meldung ausgeben?
94 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
96 $cabType = "Kabine ohne Namen";
97 $cab = $el->getPartInstance();
99 // Kabinenbeschreibung holen
100 $cabType = $cab->getObjectDescription();
103 // Debug-Meldung ausgeben
104 $this->getDebugInstance()->output(sprintf("[%s:%d] Es stehen <strong>%d</strong> Betten vom Kabinen-Typ <strong>%s</strong> bereit.<br />\n",
113 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%s</strong> ist keine Kabine.<br />\n",
116 $el->getObjectDescription()
121 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das <strong>%s</strong> mit dem Namen <strong>%s</strong> hat <strong>%d</strong> Betten.<br />\n",
124 $this->getObjectDescription(),
125 $this->getShipName(),
129 // Anzahl zurueckliefern
136 public function saveObjectToDatabase () {
137 $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
144 * Limits this object with an ObjectLimits instance
146 public function limitObject (ObjectLimits $limitInstance) {
147 ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");