X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=application%2Fship-simu%2Fmain%2Fships%2Fclass_BaseShip.php;h=14ed9d2a7a41b7b15b615603f77d36df8c720b4b;hp=c04762792229b0228eb0cc01a9e113a79999ac4d;hb=2b7c3e43b2fe0f3c5ae0455d13fa7743b638049f;hpb=3e77bae728f6e1d12434681010590465455fc2b3 diff --git a/application/ship-simu/main/ships/class_BaseShip.php b/application/ship-simu/main/ships/class_BaseShip.php index c047627..14ed9d2 100644 --- a/application/ship-simu/main/ships/class_BaseShip.php +++ b/application/ship-simu/main/ships/class_BaseShip.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -38,19 +38,15 @@ class BaseShip extends BaseSimulator { private $structures = null; // Namenloses Ship generieren - protected function __construct($class) { + protected function __construct($className) { // Call parent constructor - parent::__construct($class); - - // Set object description - $this->setObjectDescription("Allgemeines Schiff"); + parent::__construct($className); // Prepare array object for all structures $this->createStructuresArray(); // Clean-up a little $this->removePartInstance(); - $this->removeNumberFormaters(); } // Array-Objekt anlegen @@ -62,7 +58,7 @@ class BaseShip extends BaseSimulator { // buildInstance = Das was in das Schiffsteil evtl. eingebaut werden soll (null = kein besonderes Teil einbauen!) // partClass = Das zu konstruierende Schiffsteil public function createShipPart (ConstructableShipPart $buildInstance, $partClass) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s erhält ein neues Schiffsteil (%s).
\n", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s erhält ein neues Schiffsteil (%s).", __CLASS__, __LINE__, $this->getShipName(), @@ -70,19 +66,19 @@ class BaseShip extends BaseSimulator { )); // Ist die gewuenschte Klasse vorhanden? - if (class_exists($partClass)) { - // Get an instance back from our object factory - $partInstance = ObjectFactory::createObjectByName($partClass); - } else { + if (!class_exists($partClass)) { // Nicht vorhanden, dann Ausnahme werfen! throw new ClassNotFoundException($partClass, self::EXCEPTION_CLASS_NOT_FOUND); - } + } // END - if + + // Get an instance back from our object factory + $partInstance = ObjectFactory::createObjectByName($partClass); // Das Einbauen versuchen... try { $partInstance->addShipPartToShip($this, $buildInstance); } catch (MotorShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat keinen Motor erhalten! Grund: %s
\n", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat keinen Motor erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), @@ -90,7 +86,7 @@ class BaseShip extends BaseSimulator { )); return false; } catch (RoomShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat keinen Maschinenraum erhalten! Grund: %s
\n", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat keinen Maschinenraum erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), @@ -99,7 +95,7 @@ class BaseShip extends BaseSimulator { return false; } catch (StructureShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat keine Aufbauten erhalten! Grund: %s
\n", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat keine Aufbauten erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), @@ -107,7 +103,7 @@ class BaseShip extends BaseSimulator { )); return false; } catch (CabinShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat keine Kabine erhalten! Grund: %s
\n", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat keine Kabine erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), @@ -115,33 +111,18 @@ class BaseShip extends BaseSimulator { )); return false; } catch (DeckShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat kein Deck erhalten! Grund: %s
\n", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat kein Deck erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), $e->getMessage() )); return false; - } catch (ExceptionNotFoundException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Eine Exception wurde nicht gefunden. Details: %s
\n", - __CLASS__, - __LINE__, - $e->getMessage() - )); - return false; } // Instanz im Aufbauten-Array vermerken $this->structures->append($partInstance); - // Debug-Meldung ausgeben - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat das Schiffsteil %s eingebaut bekommen.
\n", - __CLASS__, - __LINE__, - $this->getShipName(), - $partInstance->getObjectDescription() - )); - // Alles klar! return true; } @@ -153,69 +134,31 @@ class BaseShip extends BaseSimulator { // STUB: Getter-Methode Anzahl Betten public function calcTotalBeds () { - $this->getDebugInstance()->output("[%s:%d] Stub! Anzahl Betten erreicht.
\n"); - return 0; + $this->partialStub("Please implement this stub in your ship!"); } // Setter-Methode fuer Schiffsnamen public final function setShipName ($shipName) { - // Cast the string - $shipName = (string) $shipName; - - // Debug message - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das neue Schiff vom Typ %s wird auf den Namen %s getauft.
\n", - __CLASS__, - __LINE__, - $this->__toString(), - $shipName - )); - - // Set ship name - $this->shipName = $shipName; + $this->shipName = (string) $shipName; } // Getter-Methode fuer Schiffsnamen public final function getShipName () { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das %s ist auf den Namen %s getauft worden.
\n", - __CLASS__, - __LINE__, - $this->__toString(), - $this->shipName - )); return $this->shipName; } // Setter-Methode fuer Tiefgang public final function setDraught ($draught) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das %s mit dem Namen %s hat einen Tiefgang von %sm.
\n", - __CLASS__, - __LINE__, - $this->__toString(), - $this->shipName, - $draught - )); $this->draught = (int) $draught; } // Getter-Methode fuer Tiefgang public final function getDraught() { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Der Tiefgang des Schiffes %s wurde angefordert.
\n", - __CLASS__, - __LINE__, - $this->shipName - )); return $this->draught; } // Setter-Methode fuer Anzahl Anker public final function setNumAnchor ($numAnchor) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das %s mit dem Namen %s hat %s Anker.
\n", - __CLASS__, - __LINE__, - $this->__toString(), - $this->shipName, - $numAnchor - )); $this->numAnchor = (int) $numAnchor; } }