class_BaseShip.php
Go to the documentation of this file.00001 <?php
00024 class BaseShip extends BaseSimulator {
00025
00026 private $shipName = "Unbekanntes Schiff";
00027
00028
00029 private $numAnchor = 0;
00030
00031
00032 private $draught = 0;
00033
00034
00035 private $crewList = null;
00036
00037
00038 private $structures = null;
00039
00040
00041 protected function __construct($className) {
00042
00043 parent::__construct($className);
00044
00045
00046 $this->createStructuresArray();
00047
00048
00049 $this->removePartInstance();
00050 }
00051
00052
00053 private function createStructuresArray () {
00054 $this->structures = new FrameworkArrayObject("FakedShipStructures");
00055 }
00056
00057
00058
00059
00060 public function createShipPart (ConstructableShipPart $buildInstance, $partClass) {
00061 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> erhält ein neues Schiffsteil (%s).",
00062 __CLASS__,
00063 __LINE__,
00064 $this->getShipName(),
00065 $partClass
00066 ));
00067
00068
00069 if (!class_exists($partClass)) {
00070
00071 throw new ClassNotFoundException($partClass, self::EXCEPTION_CLASS_NOT_FOUND);
00072 }
00073
00074
00075 $partInstance = ObjectFactory::createObjectByName($partClass);
00076
00077
00078 try {
00079 $partInstance->addShipPartToShip($this, $buildInstance);
00080 } catch (MotorShipMismatchException $e) {
00081 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat keinen Motor erhalten! Grund: <strong>%s</strong>",
00082 __CLASS__,
00083 __LINE__,
00084 $this->getShipName(),
00085 $e->getMessage()
00086 ));
00087 return false;
00088 } catch (RoomShipMismatchException $e) {
00089 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat keinen Maschinenraum erhalten! Grund: <strong>%s</strong>",
00090 __CLASS__,
00091 __LINE__,
00092 $this->getShipName(),
00093 $e->getMessage()
00094 ));
00095 return false;
00096
00097 } catch (StructureShipMismatchException $e) {
00098 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat keine Aufbauten erhalten! Grund: <strong>%s</strong>",
00099 __CLASS__,
00100 __LINE__,
00101 $this->getShipName(),
00102 $e->getMessage()
00103 ));
00104 return false;
00105 } catch (CabinShipMismatchException $e) {
00106 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat keine Kabine erhalten! Grund: <strong>%s</strong>",
00107 __CLASS__,
00108 __LINE__,
00109 $this->getShipName(),
00110 $e->getMessage()
00111 ));
00112 return false;
00113 } catch (DeckShipMismatchException $e) {
00114 if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat kein Deck erhalten! Grund: <strong>%s</strong>",
00115 __CLASS__,
00116 __LINE__,
00117 $this->getShipName(),
00118 $e->getMessage()
00119 ));
00120 return false;
00121 }
00122
00123
00124 $this->structures->append($partInstance);
00125
00126
00127 return true;
00128 }
00129
00130
00131 public final function getStructuresArray () {
00132 return $this->structures;
00133 }
00134
00135
00136 public function calcTotalBeds () {
00137 $this->partialStub("Please implement this stub in your ship!");
00138 }
00139
00140
00141 public final function setShipName ($shipName) {
00142 $this->shipName = (string) $shipName;
00143 }
00144
00145
00146 public final function getShipName () {
00147 return $this->shipName;
00148 }
00149
00150
00151 public final function setDraught ($draught) {
00152 $this->draught = (int) $draught;
00153 }
00154
00155
00156 public final function getDraught() {
00157 return $this->draught;
00158 }
00159
00160
00161 public final function setNumAnchor ($numAnchor) {
00162 $this->numAnchor = (int) $numAnchor;
00163 }
00164 }
00165
00166
00167 ?>