]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/class_WorksContract.php
More smaller fixes, factory added to ship-simu
[shipsimu.git] / application / ship-simu / main / class_WorksContract.php
index 961ef17b6567cd1c8a6455337aee97faccfabd32..cd2f0450937712276cd6003454b166802fa0e11a 100644 (file)
@@ -1,7 +1,27 @@
 <?php
-
-// Bauvertrag-Klasse
-class WorksContract extends BaseFrameworkSystem {
+/**
+ * The work constract class which can be used for contract parties
+ *
+ * @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 WorksContract extends BaseFrameworkSystem implements SignableContract {
        // Zukuenftiger Schiffsname
        private $shipName         = "";
 
@@ -21,20 +41,12 @@ class WorksContract extends BaseFrameworkSystem {
        private $merchantInstance = null;
 
        // Konstruktor
-       private function __construct () {
-               // Eltern-Konstruktor aufrufen
-               parent::constructor(__CLASS__);
-
-               // Debug message
-               if (((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
-                       $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
-                               __CLASS__,
-                               __LINE__
-                       ));
-               }
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
 
-               // Beschreibung setzen
-               $this->setPartDescr("Bauvertrag");
+               // Set description
+               $this->setObjectDescription("Bauvertrag");
 
                // Unique-ID generieren
                $this->createUniqueID();
@@ -44,7 +56,7 @@ class WorksContract extends BaseFrameworkSystem {
        }
 
        // Neuen Bauvertrag generieren
-       public static function createWorksContract ($shipType, $shipName, ContractPartner $partnerInstance) {
+       public final static function createWorksContract ($shipType, $shipName, ContractPartner $partnerInstance) {
                // Strings absichern
                $shipType = (string) $shipType;
                $shipName = (string) $shipName;
@@ -61,7 +73,7 @@ class WorksContract extends BaseFrameworkSystem {
                        throw new MissingMethodException(array($partnerInstance, 'isContractPartner'), self::EXCEPTION_MISSING_METHOD);
                }
 
-               // Instanz holen
+               // Get new instance
                $contractInstance = new WorksContract();
 
                // Debug-Meldung ausgeben
@@ -69,7 +81,7 @@ class WorksContract extends BaseFrameworkSystem {
                        __CLASS__,
                        __LINE__,
                        $shipName,
-                       $partnerInstance->getPartDescr(),
+                       $partnerInstance->getObjectDescription(),
                        $partnerInstance->getCompanyName()
                ));
 
@@ -79,7 +91,7 @@ class WorksContract extends BaseFrameworkSystem {
                // Existiert die Klasse ueberhaupt?
                if (!class_exists($shipType)) {
                        // Klasse nicht gefunden
-                       throw new ClassNotFoundException ($shipType, 0);
+                       throw new ClassNotFoundException ($shipType, self::EXCEPTION_CLASS_NOT_FOUND);
                }
 
                // Schiff-Instanz temporaer erzeugen und in den Bauvertrag einfuegen
@@ -107,7 +119,7 @@ class WorksContract extends BaseFrameworkSystem {
        }
 
        // Setter for ship instance
-       private function setShipInstance (ConstructableShip $shipInstance) {
+       private final function setShipInstance (ConstructableShip $shipInstance) {
                if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff <strong>%s</strong> wird in den Bauvertrag aufgenommen.<br />\n",
                        __CLASS__,
                        __LINE__,
@@ -117,7 +129,7 @@ class WorksContract extends BaseFrameworkSystem {
        }
 
        // Setter for ship name
-       private function setShipName ($shipName) {
+       private final function setShipName ($shipName) {
                if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das neue Schiff wird <strong>%s</strong> heissen.<br />\n",
                        __CLASS__,
                        __LINE__,
@@ -127,7 +139,7 @@ class WorksContract extends BaseFrameworkSystem {
        }
 
        // Getter for ship name
-       public function getShipName () {
+       public final function getShipName () {
                if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Schiffsname <strong>%s</strong> angefordert.<br />\n",
                        __CLASS__,
                        __LINE__,
@@ -137,7 +149,7 @@ class WorksContract extends BaseFrameworkSystem {
        }
 
        // Getter for ship instance
-       public function getShipInstance () {
+       public final function getShipInstance () {
                if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Schiff-Instanz angefordert.<br />\n",
                        __CLASS__,
                        __LINE__
@@ -211,7 +223,7 @@ class WorksContract extends BaseFrameworkSystem {
                if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[Ship:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
                        htmlentities($eval)
                ));
-               
+
                // Code ausfuhren
                @eval($eval);
 
@@ -230,7 +242,7 @@ class WorksContract extends BaseFrameworkSystem {
                                        $this->getShipInstance()->getShipName()
                                ));
                        }
-               } catch(ClassNotFoundException $e) {
+               } catch (ClassNotFoundException $e) {
                        // Throw it again...
                        throw new ClassNotFoundException($e->getMessage(), $e->getCode());
                }
@@ -242,7 +254,7 @@ class WorksContract extends BaseFrameworkSystem {
                if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%s</strong> kostet <strong>%s</strong>.<br />\n",
                        __CLASS__,
                        __LINE__,
-                       $instance->getPartDescr(),
+                       $instance->getObjectDescription(),
                        $this->getMerchantInstance()->formatCurrency($price)
                ));
 
@@ -253,32 +265,32 @@ class WorksContract extends BaseFrameworkSystem {
                if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%s</strong> wurde in den Bauvertrag aufgenommen.<br />\n",
                        __CLASS__,
                        __LINE__,
-                       $instance->getPartDescr()
+                       $instance->getObjectDescription()
                ));
        }
 
        // Setter for contract partner
-       public function setContractPartner (ContractPartner $partnerInstance) {
+       public final function setContractPartner (ContractPartner $partnerInstance) {
                $this->contractPartner = $partnerInstance;
        }
 
        // Getter for contract partner
-       public function getContractPartner () {
+       public final function getContractPartner () {
                return $this->contractPartner;
        }
 
        // Setter for contract party
-       public function setContractParty (ContractPartner $partyInstance) {
+       public final function setContractParty (ContractPartner $partyInstance) {
                $this->contractParty = $partyInstance;
        }
 
        // Getter for contract party
-       public function getContractParty () {
+       public final function getContractParty () {
                return $this->contractParty;
        }
 
        // Setter for signature
-       public function setSigned ($signed) {
+       public final function setSigned ($signed) {
                $this->signed = (boolean) $signed;
        }
 
@@ -314,9 +326,9 @@ class WorksContract extends BaseFrameworkSystem {
                                $this->getDebugInstance()->output(sprintf("[%s:%d] Die <strong>%s</strong> <em><strong>%s</strong></em> stimmt einem Bauvertrag &uuml;ber das <strong>%s</strong> <em><strong>%s</strong></em> zu.<br />\n",
                                        __CLASS__,
                                        __LINE__,
-                                       $partnerInstance->getPartDescr(),
+                                       $partnerInstance->getObjectDescription(),
                                        $partnerInstance->getCompanyName(),
-                                       $this->getShipInstance()->getPartDescr(),
+                                       $this->getShipInstance()->getObjectDescription(),
                                        $this->getShipInstance()->getShipName()
                                ));
                        } else {
@@ -324,11 +336,11 @@ class WorksContract extends BaseFrameworkSystem {
                                $this->getDebugInstance()->output(sprintf("[%s:%d] Die <strong>%s</strong> <em><strong>%s</strong></em> geht mit der <strong>%s</strong> <em><strong>%s</strong></em> einen Bauvertrag &uuml;ber das <strong>%s</strong> <em><strong>%s</strong></em> ein.<br />\n",
                                        __CLASS__,
                                        __LINE__,
-                                       $partnerInstance->getPartDescr(),
+                                       $partnerInstance->getObjectDescription(),
                                        $partnerInstance->getCompanyName(),
-                                       $partyInstance->getPartDescr(),
+                                       $partyInstance->getObjectDescription(),
                                        $partyInstance->getCompanyName(),
-                                       $this->getShipInstance()->getPartDescr(),
+                                       $this->getShipInstance()->getObjectDescription(),
                                        $this->getShipInstance()->getShipName()
                                ));
                        }
@@ -336,17 +348,17 @@ class WorksContract extends BaseFrameworkSystem {
        }
 
        // Setter for merchant instance
-       public function setMerchantInstance (Merchant $merchantInstance) {
+       public final function setMerchantInstance (Merchant $merchantInstance) {
                $this->merchantInstance = $merchantInstance;
        }
 
        // Getter for merchant instance
-       public function getMerchantInstance () {
+       public final function getMerchantInstance () {
                return $this->merchantInstance;
        }
 
        // Getter for total price
-       public function getTotalPrice () {
+       public final function getTotalPrice () {
                // Get ship instance
                $shipInstance = $this->getShipInstance();