class_BaseCabinStructure.php

Go to the documentation of this file.
00001 <?php
00024 class BaseCabinStructure extends BaseStructure {
00025         // --- Besondere Eigenschaften dazufuegen: ---
00026         // Anzahl der Kabinen im Schiff
00027         private $numCabin = 0;
00028 
00029         // Anzahl Raeume pro Kabine (kann auch nur 1 sein)
00030         private $numRooms = 0;
00031 
00032         // Anzahl Betten, verallgemeinert
00033         private $numBeds = 0;
00034 
00035         // Konstruktor
00036         protected function __construct ($className) {
00037                 // Call parent constructor
00038                 parent::__construct($className);
00039         }
00040 
00041         // Kabine hinzufuegen
00042         public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) {
00043                 // Eltern-Methode aufrufen
00044                 parent::addShipPartToShip ($shipInstance, $cabinInstance);
00045 
00046                 // Restlichen Daten ebenfalls
00047                 $this->setNumCabin($cabinInstance->numCabin);
00048                 $this->setNumRooms($cabinInstance->numRooms);
00049                 $this->setNumBeds($cabinInstance->numBeds);
00050 
00051                 // Unnoetige Attribute entfernen
00052                 $cabinInstance->removeNumCabin();
00053                 $cabinInstance->removeNumRooms();
00054                 $cabinInstance->removeNumBeds();
00055 
00056                 // Instanz setzen
00057                 $this->setDeckInstance($cabinInstance);
00058         }
00059 
00060         // Wrapper fuer setDeckInstance->setPartInstance
00061         public final function setDeckInstance ($deck) {
00062                 parent::setPartInstance($deck);
00063         }
00064 
00065         // Getter-Methode fuer Anzahl Betten
00066         public final function getNumBeds () {
00067                 return $this->numBeds;
00068         }
00069 
00070         // Getter-Methode fuer Anzahl Kabinen
00071         public final function getNumCabin () {
00072                 return $this->numCabin;
00073         }
00074 
00075         // Setter-Methode fuer Anzahl Betten
00076         public final function setNumBeds ($numBeds) {
00077                 $this->numBeds = $numBeds;
00078         }
00079 
00080         // Setter-Methode fuer Anzahl Raeume
00081         public final function setNumRooms ($numRooms) {
00082                 $this->numRooms = $numRooms;
00083         }
00084 
00085         // Setter-Methode fuer Anzahl Kabinen
00086         public final function setNumCabin ($numCabin) {
00087                 $this->numCabin = $numCabin;
00088         }
00089 
00090         // Loesch-Methode fuer Anzahl Betten
00091         public final function removeNumBeds() {
00092                 unset($this->numBeds);
00093         }
00094 
00095         // Loesch-Methode fuer Anzahl Kabinen
00096         public final function removeNumCabin() {
00097                 unset($this->numCabin);
00098         }
00099 
00100         // Loesch-Methode fuer Anzahl Raeume
00101         public final function removeNumRooms() {
00102                 unset($this->numRooms);
00103         }
00104 
00105         // Bettenanzahl pro Kabine berechnen
00106         public function calcTotalBedsByCabin () {
00107                 // Dann Bettenanzahl holen und aufaddieren
00108                 $beds = $this->getNumBeds();
00109                 $num  = $this->getNumCabin();
00110                 $cabinBeds = $beds * $num;
00111                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) {
00112                         // Get new instance
00113                         $cabType = "Kabine ohne Namen";
00114                         $cab = $this->getPartInstance();
00115                         if (!is_null($cab)) {
00116                                 // Kabinenbeschreibung holen
00117                                 $cabType = $cab->__toString();
00118                         }
00119 
00120                         // Debug-Meldung ausgeben
00121                         $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.",
00122                                 __CLASS__,
00123                                 __LINE__,
00124                                 $num,
00125                                 $cabType,
00126                                 $beds,
00127                                 $cabinBeds
00128                         ));
00129                 }
00130                 return $cabinBeds;
00131         }
00132 }
00133 
00134 // [EOF]
00135 ?>

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