class_PassengerShip.php

Go to the documentation of this file.
00001 <?php
00025 class PassengerShip extends BaseShip implements ConstructableShip {
00026         // Konstruktor
00027         protected function __construct () {
00028                 // Eltern-Kontruktor aufrufen
00029                 parent::__construct(__CLASS__);
00030 
00031                 // Clean up a little
00032                 $this->removeSystemArray();
00033                 $this->removeNumberFormaters();
00034         }
00035 
00036         // Passagier-Schiff erstellen
00037         public final static function createPassengerShip ($shipName) {
00038                 // Get new instance
00039                 $passInstance = new PassengerShip();
00040 
00041                 // Set ship name
00042                 $passInstance->setShipName($shipName);
00043 
00044                 // Instanz zurueckgeben
00045                 return $passInstance;
00046         }
00047 
00048         // Anzahl Betten ermitteln
00049         public final function calcTotalBeds () {
00050                 // Struktur-Array holen
00051                 $struct = $this->getStructuresArray();
00052 
00053                 if (is_null($struct)) {
00054                         // Empty structures list!
00055                         throw new EmptyStructuresListException($this, self::EXCEPTION_EMPTY_STRUCTURES_ARRAY);
00056                 } // END - if
00057 
00058                 // Anzahl Betten auf 0 setzen
00059                 $numBeds = 0;
00060 
00061                 // Alle Strukturen nach Kabinen durchsuchen
00062                 for ($idx = $struct->getIterator(); $idx->valid(); $idx->next()) {
00063                         // Element holen
00064                         $el = $idx->current();
00065 
00066                         // Ist es eine Kabine?
00067                         if ($el->isCabin()) {
00068                                 // Anzahl Betten ermitteln
00069                                 $total = $el->calcTotalBedsByCabin();
00070                                 $numBeds += $total;
00071 
00072                                 // Debug-Meldung ausgeben?
00073                                 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
00074                                         // Get new instance
00075                                         $cabType = "Kabine ohne Namen";
00076                                         $cab = $el->getPartInstance();
00077                                         if (!is_null($cab)) {
00078                                                 // Kabinenbeschreibung holen
00079                                                 $cabType = $cab->getObjectDescription();
00080                                         } // END - if
00081                                 } // END - if
00082                         } // END - if
00083                 } // END - for
00084 
00085                 // Anzahl zurueckliefern
00086                 return $numBeds;
00087         }
00088 }
00089 
00090 // [EOF]
00091 ?>

Generated on Mon Dec 8 01:06:44 2008 for Ship-Simulator by  doxygen 1.5.6