]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/ships/class_BaseShip.php
Just a space removed
[shipsimu.git] / application / ship-simu / main / ships / class_BaseShip.php
index d7c394b1e7930bdc164dd551c3017f46ae199648..a37bdb03c291422d67bcff85b0b45159c23a891e 100644 (file)
@@ -1,4 +1,26 @@
 <?php
+/**
+ * A general ship class for all other kinds of ships even small sail ships
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
 class BaseShip extends BaseSimulator {
        // Name des Shipes
        private $shipName   = "Unbekanntes Schiff";
@@ -16,36 +38,24 @@ class BaseShip extends BaseSimulator {
        private $structures = null;
 
        // Namenloses Ship generieren
-       private function __construct($class) {
+       protected function __construct($class) {
                // Call parent constructor
-               parent::constructor($class);
+               parent::__construct($class);
 
-               // Beim Schiff angelangt
-               if (((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT')))
-                       $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
-                               __CLASS__,
-                               __LINE__
-                       ));
-
-               // Bezeichnung setzen
-               $this->setPartDescr("Schiff");
+               // Set object description
+               $this->setObjectDescription("Allgemeines Schiff");
 
-               // Array-Objekt generieren
+               // Prepare array object for all structures
                $this->createStructuresArray();
-               // Instanz entfernen
+
+               // Clean-up a little
                $this->removePartInstance();
                $this->removeNumberFormaters();
        }
 
-       // Konstruktor aufrufen
-       public function constructor ($class) {
-               $this->__construct($class);
-       }
-
        // Array-Objekt anlegen
        private function createStructuresArray () {
-               $this->structures = new FrameworkArrayObject();
+               $this->structures = new FrameworkArrayObject("FakedShipStructures");
        }
 
        // Schiffsteil generieren (kann alles sein)
@@ -61,23 +71,11 @@ class BaseShip extends BaseSimulator {
 
                // Ist die gewuenschte Klasse vorhanden?
                if (class_exists($partClass)) {
-                       // Befehl zusammenbauen
-                       $eval = sprintf("\$partInstance = %s::create%s();",
-                               $partClass, $partClass
-                       );
-
-                       // Debug-Meldung ausgeben
-                       if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
-                               __CLASS__,
-                               __LINE__,
-                               htmlentities($eval)
-                       ));
-
-                       // ... und ausfuehren
-                       eval($eval);
+                       // Get an instance back from our object factory
+                       $partInstance = ObjectFactory::createObjectByName($partClass);
                } else {
                        // Nicht vorhanden, dann Ausnahme werfen!
-                       throw new ClassNotFoundException($partClass, 0);
+                       throw new ClassNotFoundException($partClass, self::EXCEPTION_CLASS_NOT_FOUND);
                }
 
                // Das Einbauen versuchen...
@@ -148,7 +146,7 @@ class BaseShip extends BaseSimulator {
                        __CLASS__,
                        __LINE__,
                        $this->getShipName(),
-                       $partInstance->getPartDescr()
+                       $partInstance->getObjectDescription()
                ));
 
                // Alles klar!
@@ -156,7 +154,7 @@ class BaseShip extends BaseSimulator {
        }
 
        // Getter-Methode fuer Strukturen-Array
-       public function getStructuresArray () {
+       public final function getStructuresArray () {
                return $this->structures;
        }
 
@@ -167,7 +165,7 @@ class BaseShip extends BaseSimulator {
        }
 
        // Setter-Methode fuer Schiffsnamen
-       public function setShipName ($shipName) {
+       public final function setShipName ($shipName) {
                // Cast the string
                $shipName = (string) $shipName;
 
@@ -184,7 +182,7 @@ class BaseShip extends BaseSimulator {
        }
 
        // Getter-Methode fuer Schiffsnamen
-       public function getShipName () {
+       public final function getShipName () {
                if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das <strong>%s</strong> ist auf den Namen <strong>%s</strong> getauft worden.<br />\n",
                        __CLASS__,
                        __LINE__,
@@ -195,7 +193,7 @@ class BaseShip extends BaseSimulator {
        }
 
        // Setter-Methode fuer Tiefgang
-       public function setDraught ($draught) {
+       public final function setDraught ($draught) {
                if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das <strong>%s</strong> mit dem Namen <strong>%s</strong> hat einen Tiefgang von <strong>%sm</strong>.<br />\n",
                        __CLASS__,
                        __LINE__,
@@ -207,7 +205,7 @@ class BaseShip extends BaseSimulator {
        }
 
        // Getter-Methode fuer Tiefgang
-       public function getDraught() {
+       public final function getDraught() {
                if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Der Tiefgang des Schiffes <strong>%s</strong> wurde angefordert.<br />\n",
                        __CLASS__,
                        __LINE__,
@@ -217,7 +215,7 @@ class BaseShip extends BaseSimulator {
        }
 
        // Setter-Methode fuer Anzahl Anker
-       public function setNumAnchor ($numAnchor) {
+       public final function setNumAnchor ($numAnchor) {
                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>%s</strong> Anker.<br />\n",
                        __CLASS__,
                        __LINE__,