X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=application%2Fship-simu%2Fmain%2Fcompanies%2Fclass_ShippingCompany.php;h=de959b62f836e6f272d9de6d6e74e676a24994bf;hp=3fca7ead55b1f29b18f3b59c672bc25daf197eaf;hb=4f70843ae8428f051d70ccff5bb43fc4c03dda8d;hpb=a76d51b4096b47436e269156547f02713d95af5b diff --git a/application/ship-simu/main/companies/class_ShippingCompany.php b/application/ship-simu/main/companies/class_ShippingCompany.php index 3fca7ea..de959b6 100644 --- a/application/ship-simu/main/companies/class_ShippingCompany.php +++ b/application/ship-simu/main/companies/class_ShippingCompany.php @@ -1,6 +1,26 @@ + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 . + */ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner { /** * Full name of this company @@ -18,14 +38,14 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner private $founderInstance = null; /** - * Employed people by this company + * Headquarter harbor instance */ - private $employeeList = null; + private $hqInstance = null; /** - * Headquarter harbor instance + * Employed people by this company */ - private $hqInstance = null; + private $employeeList = null; /** * List of all assigned shipyards @@ -42,101 +62,161 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner */ private $contractList = null; + // Exception constants + const EXCEPTION_USER_OWNS_NO_COMPANY = 0x200; + /** - * Main constructor + * Protected constructor * * @return void */ - private function __construct () { + protected function __construct () { // Call parent constructor - parent::constructor(__CLASS__); + parent::__construct(__CLASS__); + } - // Debug message - if (((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) { - $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.
\n", - __CLASS__, - __LINE__ - )); - } + /** + * Creates an instance of this company class or throws an exception if the + * given user owns no company. + * + * @param $userInstance A user class + * @return $companyInstance Prepared company instance + * @todo Add functionality if user participates in a company + */ + public static final function createShippingCompany (ManageableAccount $userInstance) { + // Get new instance + $companyInstance = new ShippingCompany(); - // Set description - $this->setPartDescr("Reederei"); + // Does the given user owns a company? + if ($companyInstance->ifUserParticipatesInCompany($userInstance)) { + // Then do some nasty caching here but don't throw an exception + // because then you will hurt our web helpers... :/ + $companyInstance->partialStub("Don't throw exceptions here."); + } // END - if - // Generate unique ID number - $this->createUniqueID(); + // Init all lists + $companyInstance->initCompanyLists(); - // Clean up a little - $this->removeSystemArray(); + // Return instance + return $companyInstance; } - // Reederei gruenden (create wegen Namenskonvention) - public static function createShippingCompany ($companyName, Harbor $hqInstance) { - // Get new instance - $companyInstance = new ShippingCompany(); + /** + * Checks wether the given user participates in a company + * + * @param $userInstance An instance of a user class + * @return $participates Wether the user participates at lease in one company + */ + protected function ifUserParticipatesInCompany (ManageableAccount $userInstance) { + // By default no user owns any company... ;) + $participates = false; - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $companyInstance->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s wird gegründet.
\n", - __CLASS__, - __LINE__, - $companyName - )); + // Get a company database wrapper class + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('company_db_wrapper_class', array($this)); - // Firmennamen setzen - $companyInstance->setCompanyName($companyName); + // Ask the wrapper if this user participates + $participates = $wrapperInstance->ifUserParticipatesInCompany($userInstance); - // Kuerzel setzen - $companyInstance->createShortName(); + // Get the result instance + $resultInstance = $wrapperInstance->getResultInstance(); - // Sitz festlegen - $companyInstance->setHQInstance($hqInstance); + // Caches the result instance here, if set (we don't the wrapper anymore!) + if ($resultInstance instanceof SearchableResult) { + // Set the result instance + $this->setResultInstance($resultInstance); + } // END - if - // Werftenliste erstellen - $companyInstance->createshipyardList(); + // Return result + return $participates; + } - // Angestellten-Liste erstellen - $companyInstance->createEmployeeList(); + /** + * Checks wether the current user in registry is the company founder + * + * @return $isFounder Wether the current user is the company founder + * @todo Check if user is company founder + */ + public function ifUserIsFounder () { + // Default is not the founder + $isFounder = false; - // Auftragsliste erstellen - $companyInstance->createContractList(); + // Get result instance + $resultInstance = $this->getResultInstance(); - // Clean up a little - $companyInstance->removeWidth(); - $companyInstance->removeHeight(); - $companyInstance->removeLength(); - $companyInstance->removeDraught(); - $companyInstance->removePartInstance(); + // Is it set? + if ($resultInstance instanceof SearchableResult) { + // Result found so analyse it + $this->partialStub("Check if user is company founder."); + } // END - if - // Instanz zurueckgeben - return $companyInstance; + // Return result + return $isFounder; } - // Angestellten-Liste erstellen - private function createEmployeeList () { - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s erhält eine Angestelltenliste.
\n", - __CLASS__, - __LINE__, - $this->getCompanyName() - )); - $this->employeeList = new FrameworkArrayObject(); + /** + * Checks wether the current user in registry is the company owner + * + * @return $isOwner Wether the current user is the company owner + * @todo Check if user is company owner + */ + public function ifUserIsOwner () { + // Default is not the owner + $isOwner = false; + + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Is it set? + if ($resultInstance instanceof SearchableResult) { + // Result found so analyse it + $this->partialStub("Check if user is company owner."); + } // END - if + + // Return result + return $isOwner; } - // Werftenliste erstellen - public function createShipyardList () { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s erhält eine Werftsliste.
\n", - __CLASS__, - __LINE__, - $this->getCompanyName() - )); - $this->shipyardList = new FrameworkArrayObject(); + /** + * Checks wether the current user in registry is an employee in this company + * + * @return $isOwner Wether the current user is an employee in this company + */ + public function ifUserIsEmployee () { + // Default is no employee + $isEmployee = false; + + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Is it set? + if ($resultInstance instanceof SearchableResult) { + // Result found so he is employee + $isEmployee = true; + } // END - if + + // Return result + return $isEmployee; } - // Auftragsliste erstellen - public function createContractList () { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s erhält eine Auftragsliste.
\n", - __CLASS__, - __LINE__, - $this->getCompanyName() - )); - $this->contractList = new FrameworkArrayObject(); + //------------------------------------------------------------------------------\ + // Below here is very old code which needs to be translated and changed heavily | + //------------------------------------------------------------------------------/ + + /** + * Intialize all lists + * + * @return void + * @todo Maybe we don't need these big lists anymore?! So we can deprecate/remove it + */ + protected function initCompanyLists () { + // Employees + $this->employeeList = new FrameworkArrayObject("FakedEmployeeList"); + + // Ship yards + $this->shipyardList = new FrameworkArrayObject("FakedShipyardList"); + + // Contracts + $this->contractList = new FrameworkArrayObject("FakedContractList"); } // Setter-Methode fuer Firmennamen @@ -155,17 +235,17 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner } // Kuerzel setzen - private function createShortName () { + private function initShortName () { // Mindestens eine Leerstelle? $dummy = explode(" ", $this->getCompanyName()); foreach ($dummy as $part) { $this->shortName .= substr($part, 0, 1); - } + } // END - if } // Reedereien Werften bauen lassen public function createShipyardInHarbor($shipyardName, Harbor $harborInstance) { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s baut im %s eine Werft %s.
\n", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s baut im %s eine Werft %s.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -186,13 +266,6 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Setter fuer Reederei-Gruender public final function setCompanyFounder(CompanyEmployee $founderInstance) { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s ist von %s %s gegründet worden.
\n", - __CLASS__, - __LINE__, - $this->getCompanyName(), - $founderInstance->getSurname(), - $founderInstance->getFamily() - )); $this->founderInstance = $founderInstance; } @@ -203,26 +276,11 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Neue(n) Angestellte(n) in Angestellten-Liste aufnehmen public function addNewEmployee (SimulatorPersonell $employeeInstance) { - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] %s %s tritt der Reederei %s als %s bei und erhält ein Gehalt von %s.
\n", - __CLASS__, - __LINE__, - $employeeInstance->getSurname(), - $employeeInstance->getFamily(), - $this->getCompanyName(), - $employeeInstance->getPartDescr(), - $this->formatCurrency($employeeInstance->getSalary()) - )); $this->employeeList->append($employeeInstance); } // Neue Werft in Liste aufnehmen public function addNewShipyard (Shipyard $shipyardInstance) { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s erhält die Werft %s hinzugefügt.
\n", - __CLASS__, - __LINE__, - $this->getCompanyName(), - $shipyardInstance->getShipyardName() - )); $this->shipyardList->append($shipyardInstance); } @@ -232,7 +290,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $amount = (int) $amount; // Debug-Meldung ausgeben - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s stellt per Zufall %d neue Mitarbeiter ein.
\n", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s stellt per Zufall %d neue Mitarbeiter ein.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -246,7 +304,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner if ($totalUnemployed < $amount) { // Reichte nicht aus! throw new ToMuchEmployeesException(array($amount, $personellInstance->getAllUnemployed()), self::EXCEPTION_NOT_ENOUGTH_UNEMPLOYEES); - } + } // END - if // Get list for all unemployed people $list = $personellInstance->getSpecialPersonellList(false); // Should be cached @@ -267,26 +325,25 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $iterator->seek($pos); // Is the current position valid? - if ($iterator->valid()) { - // Element holen - $employee = $iterator->current(); - } else { - // Should�normally not happen... :( + if ($iterator->valid() === false) { + // Should normally not happen... :( throw new StructuresOutOfBoundsException($idx, self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } - } + } // END - if + + // Get current element + $employee = $iterator->current(); + } // END - while // A dummy just for the description and real class $dummy = CompanyEmployee::createCompanyEmployee("", "", "M", 1970, 1, 1, $employee->isMarried(), 0); // Make this person employed and give him some money to work $employee->setEmployed(true); - $employee->setPartDescr($dummy->getPartDescr()); $employee->setRealClass($dummy->__toString()); $employee->increaseSalary((mt_rand(7, 14) * 100)); // Are 700 to 1400 EUR for the begin okay? // Debug message - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s stellt den/die Angestellte(n) %s %s ein.
\n", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s stellt den/die Angestellte(n) %s %s ein.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -302,7 +359,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $personellInstance->resetCache(); // Debug-Meldung ausgeben - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s hat per Zufall %d neue Mitarbeiter eingestellt.
\n", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s hat per Zufall %d neue Mitarbeiter eingestellt.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -312,7 +369,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Distribute all personells on all shipyards public function distributeAllPersonellOnShipyards () { - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s verteilt alle ihre %d Mitarbeiter auf alle %d Werft(en).
\n", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s verteilt alle ihre %d Mitarbeiter auf alle %d Werft(en).", __CLASS__, __LINE__, $this->getCompanyName(), @@ -332,10 +389,10 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Iterate through all employees for ($idx = $this->employeeList->getIterator(); $idx->valid(); $idx->next()) { // Is the shipyard iterator still okay? - if (!$shipyardIter->valid()) { + if ($shipyardIter->valid() === false) { // Rewind to first position $shipyardIter->seek(0); - } + } // END - if // Get Shipyard object $shipyard = $shipyardIter->current(); @@ -346,8 +403,8 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($shipyard)) { // Not an object! ;-( - throw new NoObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!$shipyard->isSameClass("Shipyard")) { + throw new InvalidObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); + } elseif ($shipyard->isClass("Shipyard") === false) { // Nope, so throw exception throw new ClassMismatchException(array($shipyard->__toString(), "Shipyard"), self::EXCEPTION_CLASSES_NOT_MATCHING); } @@ -366,7 +423,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $total = $this->employeeList->count(); // Debug message - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s hat %d Mitarbeiter.
\n", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s hat %d Mitarbeiter.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -379,7 +436,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Getter for total shipyards public final function getTotalShipyards () { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Für die Reederei %s werden die Anzahl der Werften in allen Häfen ermittelt.
\n", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Für die Reederei %s werden die Anzahl der Werften in allen Häfen ermittelt.", __CLASS__, __LINE__, $this->getCompanyName() @@ -395,7 +452,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $total = $this->shipyardList->count(); // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s hat %d Werft(en).
\n", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s hat %d Werft(en).", __CLASS__, __LINE__, $this->getCompanyName(), @@ -414,7 +471,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Is the class there? if (!class_exists($shipType)) { // Throw exception - throw new ClassNotFoundException($shipType, 0); + throw new NoClassException($shipType, self::EXCEPTION_CLASS_NOT_FOUND); } // Create dummy ship @@ -423,14 +480,6 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $shipType )); - // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s baut in allen Werften bald Schiffe vom Typ %s.
\n", - __CLASS__, - __LINE__, - $this->getCompanyName(), - $shipInstance->getPartDescr() - )); - // Iterate shipyard list for ($idx = $this->shipyardList->getIterator(); $idx->valid(); $idx->next()) { // Get current element @@ -442,26 +491,19 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($shipyard)) { // Not an object! ;-( - throw new NoObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!$shipyard->isSameClass("Shipyard")) { + throw new InvalidObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); + } elseif ($shipyard->isClass("Shipyard") === false) { // Class is not a shipyard throw new ClassMismatchException(array($shipyard->__toString(), "Shipyard"), self::EXCEPTION_CLASSES_NOT_MATCHING); } // Add the new ship type to the shipyard $shipyard->addNewConstructableShipType($shipType); - } + } // END - for } // Validate the requested ship type with the company if they can construct it public function validateWorksContractShipType (SignableContract $contractInstance) { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s prüft den Bauauftrag der %s.
\n", - __CLASS__, - __LINE__, - $this->getCompanyName(), - $contractInstance->getShipName() - )); - // First get the ship type $shipInstance = $contractInstance->getShipInstance(); @@ -471,22 +513,13 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($shipInstance)) { // Not an object! ;-( - throw new NoObjectException($shipInstance, self::EXCEPTION_IS_NO_OBJECT); + throw new InvalidObjectException($shipInstance, self::EXCEPTION_IS_NO_OBJECT); } // Get it's real class name $shipType = $shipInstance->__toString(); - // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s prüft, ob die %s (Typ:%s) gebaut werden kann.
\n", - __CLASS__, - __LINE__, - $this->getCompanyName(), - $contractInstance->getShipName(), - $shipInstance->getPartDescr() - )); - - // Now check if the ship type is in any list and return the result + // Now check if ship type is in any list and return the result return ($this->isShipTypeConstructable($shipType)); } @@ -496,7 +529,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $shipType = (string) $shipType; // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s fragt alle Werften ab, ob diese Schiffe vom Typ %s bauen können.
\n", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s fragt alle Werften ab, ob diese Schiffe vom Typ %s bauen können.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -517,21 +550,21 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($shipyard)) { // Not an object! ;-( - throw new NoObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!$shipyard->isSameClass("Shipyard")) { + throw new InvalidObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); + } elseif ($shipyard->isClass("Shipyard") === false) { // Class is not a shipyard throw new ClassMismatchException(array($shipyard->__toString(), "Shipyard"), self::EXCEPTION_CLASSES_NOT_MATCHING); } - // Validate if the first found shipyard can construct the requested type + // Validate if first found shipyard can construct the requested type $result = $shipyard->isShipTypeConstructable($shipType); - //�Does this shipyard construct the requested ship type? + // Does this shipyard construct the requested ship type? if ($result) break; // Then abort the search! - } + } // END - for // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s hat die Suche nach einer Werft beendet, die Schiffe vom Typ %s bauen kann.
\n", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s hat die Suche nach einer Werft beendet, die Schiffe vom Typ %s bauen kann.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -544,13 +577,6 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // As a customer the shipping company can add new contracts public function addNewWorksContract (SignableContract $contractInstance) { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s erstellt einen Bauauftrag für ein %s mit dem Namen %s.
\n", - __CLASS__, - __LINE__, - $this->getCompanyName(), - $contractInstance->getShipInstance()->getPartDescr(), - $contractInstance->getShipInstance()->getShipName() - )); $this->contractList->append($contractInstance); } @@ -574,28 +600,28 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Sign a contract with an other party which must also implement Customer public function signContract (SignableContract $contractInstance, ContractPartner $partnerInstance) { // Check wether the other party is our contract partner - if (!$partnerInstance->isContractPartner($contractInstance)) { + if ($partnerInstance->isContractPartner($contractInstance) === false) { // Invalid contract partner! throw new InvalidContractPartnerException($partnerInstance, self::EXCEPTION_CONTRACT_PARTNER_INVALID); - } + } // END - if // Determine if company "signs" own contract (must be done) or with an other party if ($this->equals($partnerInstance)) { // With itself - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s erteilt an sich selbst einen Bauauftrag für das %s "%s".
\n", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s erteilt an sich selbst einen Bauauftrag für das %s "%s".", __CLASS__, __LINE__, $this->getCompanyName(), - $contractInstance->getShipInstance()->getPartDescr(), + $contractInstance->getShipInstance()->getObjectDescription(), $contractInstance->getShipInstance()->getShipName() )); } else { // Other external company - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s unterzeichnet einen Bauauftrag für das %s "%s" mit der %s.
\n", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s unterzeichnet einen Bauauftrag für das %s "%s" mit der %s.", __CLASS__, __LINE__, $this->getCompanyName(), - $contractInstance->getShipInstance()->getPartDescr(), + $contractInstance->getShipInstance()->getObjectDescription(), $contractInstance->getShipInstance()->getShipName(), $partnerInstance->getCompanyName() )); @@ -625,8 +651,8 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($contractInstance)) { // Not an object! ;-( - throw new NoObjectException($contractInstance, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!$contractInstance->isSameClass('WorksContract')) { + throw new InvalidObjectException($contractInstance, self::EXCEPTION_IS_NO_OBJECT); + } elseif ($contractInstance->isClass("WorksContract") === false) { // Is not a merchant throw new ClassMismatchException(array($contractInstance->__toString(), "WorksContract"), self::EXCEPTION_CLASSES_NOT_MATCHING); } @@ -634,23 +660,6 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Set the merchant in the contract (for getting prices) $contractInstance->setMerchantInstance($merchantInstance); } - - /** - * Stub! - */ - public function saveObjectToDatabase () { - $this->getDebugInstance()->output(sprintf("[%s:] Stub %s erreicht.", - $this->__toString(), - __FUNCTION__ - )); - } - - /** - * Limits this object with an ObjectLimits instance - */ - public function limitObject (ObjectLimits $limitInstance) { - ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!"); - } } // [EOF]