--- /dev/null
+<?php
+
+// Die Reederei-Klasse
+class ShippingCompany extends BaseSimulator implements Customer, ContractPartner {
+ // Firmenname
+ private $companyName = "Namenlose Reederei";
+
+ // Firmenkuerzel
+ private $shortName = "";
+
+ // Reederei-Gruender
+ private $founderInstance = null;
+
+ // Angestellten-Liste
+ private $employeeList = null;
+
+ // Zugewiesener Hafen
+ private $hqInstance = null;
+
+ // Werftenliste
+ private $shipyardList = null;
+
+ // Der Reederei gehoerenden Schiffe
+ private $ownedShips = null;
+
+ // Bauauftraege als Kunde
+ private $contractList = null;
+
+ // Konstruktor
+ private function __construct () {
+ // Eltern-Konstruktor aufrufen
+ parent::constructor(__CLASS__);
+
+ // Debug message
+ if (((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
+ $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
+ __CLASS__,
+ __LINE__
+ ));
+ }
+
+ // Beschreibung setzen
+ $this->setPartDescr("Reederei");
+
+ // Unique-ID erzeugen
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeSystemArray();
+ }
+
+ // Reederei gruenden (create wegen Namenskonvention)
+ public static function createShippingCompany ($companyName, Harbor $hqInstance) {
+ // Instanz holen
+ $companyInstance = new ShippingCompany();
+
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $companyInstance->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> wird gegründet.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $companyName
+ ));
+
+ // Firmennamen setzen
+ $companyInstance->setCompanyName($companyName);
+
+ // Kuerzel setzen
+ $companyInstance->createShortName();
+
+ // Sitz festlegen
+ $companyInstance->setHQInstance($hqInstance);
+
+ // Werftenliste erstellen
+ $companyInstance->createshipyardList();
+
+ // Angestellten-Liste erstellen
+ $companyInstance->createEmployeeList();
+
+ // Auftragsliste erstellen
+ $companyInstance->createContractList();
+
+ // Etwas aufraeumen
+ $companyInstance->removeWidth();
+ $companyInstance->removeHeight();
+ $companyInstance->removeLength();
+ $companyInstance->removeDraught();
+ $companyInstance->removePartInstance();
+
+ // Instanz zurueckgeben
+ return $companyInstance;
+ }
+
+ // Angestellten-Liste erstellen
+ private function createEmployeeList () {
+ if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> erhält eine Angestelltenliste.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName()
+ ));
+ $this->employeeList = new FrameworkArrayObject();
+ }
+
+ // Werftenliste erstellen
+ public function createShipyardList () {
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> erhält eine Werftsliste.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName()
+ ));
+ $this->shipyardList = new FrameworkArrayObject();
+ }
+
+ // Auftragsliste erstellen
+ public function createContractList () {
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> erhält eine Auftragsliste.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName()
+ ));
+ $this->contractList = new FrameworkArrayObject();
+ }
+
+ // Setter-Methode fuer Firmennamen
+ public function setCompanyName ($companyName) {
+ $this->companyName = (string) $companyName;
+ }
+
+ // Getter-Methode fuer Firmennamen
+ public function getCompanyName () {
+ return $this->companyName;
+ }
+
+ // Setter-Methode fuer Firmensitz
+ public function setHQInstance (Harbor $hqInstance) {
+ $this->hqInstance = $hqInstance;
+ }
+
+ // Kuerzel setzen
+ private function createShortName () {
+ // Mindestens eine Leerstelle?
+ $dummy = explode(" ", $this->getCompanyName());
+ foreach ($dummy as $part) {
+ $this->shortName .= substr($part, 0, 1);
+ }
+ }
+
+ // 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 <strong>%s</strong> baut im <strong>%s</strong> eine Werft <strong>%s</strong>.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $harborInstance->getHarborName(),
+ $shipyardName
+ ));
+
+ // Wird im HQ gebaut?
+ if ($this->hqInstance->equals($harborInstance)) {
+ // Die neue Werft wird im HQ gebaut!
+ $this->hqInstance->addNewShipyardNotify($shipyardName, $this);
+ // Die Werft drueber in Kenntnis setzen, welcher Reederei sie angehoert
+ } else {
+ // Ausserhalb des Heimathafens soll eine Werft gebaut werden
+ $harborInstance->addNewShipyardNotify($shipyardName, $this);
+ }
+ }
+
+ // Setter fuer Reederei-Gruender
+ public function setCompanyFounder(CompanyEmployee $founderInstance) {
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> ist von <strong>%s %s</strong> gegründet worden.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $founderInstance->getSurname(),
+ $founderInstance->getFamily()
+ ));
+ $this->founderInstance = $founderInstance;
+ }
+
+ // Getter for founder instance
+ public function getFounderInstance () {
+ return $this->founderInstance;
+ }
+
+ // 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] <strong>%s %s</strong> tritt der Reederei <strong>%s</strong> als <strong>%s</strong> bei und erhält ein Gehalt von <strong>%s</strong>.<br />\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 <strong>%s</strong> erhält die Werft <strong>%s</strong> hinzugefügt.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $shipyardInstance->getShipyardName()
+ ));
+ $this->shipyardList->append($shipyardInstance);
+ }
+
+ // Neue Mitarbeiter per Zufall einstellen/rekrutieren
+ public function recruitRandomEmployees($amount, SimulatorPersonell $personellInstance) {
+ // Anzahl Mitarbeiter absichern
+ $amount = (int) $amount;
+
+ // Debug-Meldung ausgeben
+ if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> stellt per Zufall <strong>%d</strong> neue Mitarbeiter ein.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $amount
+ ));
+
+ // Gesamtanzahl verfuegbarer Erwerbsloser holen
+ $totalUnemployed = $personellInstance->getAllUnemployed();
+
+ // Existiert die gewuenschte Anzahl freier Arbeiter? (doppelt geht derzeit nicht)
+ if ($totalUnemployed < $amount) {
+ // Reichte nicht aus!
+ throw new ToMuchEmployeesException(array($amount, $personellInstance->getAllUnemployed()), self::EXCEPTION_NOT_ENOUGTH_UNEMPLOYEES);
+ }
+
+ // Get list for all unemployed people
+ $list = $personellInstance->getSpecialPersonellList(false); // Should be cached
+
+ // Get iterator of the list
+ $iterator = $list->getIterator();
+
+ // Get the requested amount of personell
+ for ($idx = 0; $idx < $amount; $idx++) {
+ $employee = null;
+ // Is this personl unemployed?
+ while (is_null($employee) || $employee->isEmployed()) {
+ // Generate random number
+ $pos = mt_rand(0, ($totalUnemployed - 1)); // Don't remove the -1 here:
+ // E.g. 100 entries means latest position is 99...
+
+ // Seek for the position
+ $iterator->seek($pos);
+
+ // Is the current position valid?
+ if ($iterator->valid()) {
+ // Element holen
+ $employee = $iterator->current();
+ } else {
+ // Should normally not happen... :(
+ throw new StructuresOutOfBoundsException($idx, self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
+ }
+ }
+
+ // 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 <strong>%s</strong> stellt den/die Angestellte(n) <strong>%s %s</strong> ein.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $employee->getSurname(),
+ $employee->getFamily()
+ ));
+
+ // Add this employee
+ $this->addNewEmployee($employee);
+ } // End - for
+
+ // Cache resetten
+ $personellInstance->resetCache();
+
+ // Debug-Meldung ausgeben
+ if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> hat per Zufall <strong>%d</strong> neue Mitarbeiter eingestellt.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $amount
+ ));
+ } // End - method
+
+ // 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 <strong>%s</strong> verteilt alle ihre <strong>%d</strong> Mitarbeiter auf alle <strong>%d</strong> Werft(en).<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $this->getTotalEmployee(),
+ $this->getTotalShipyards()
+ ));
+
+ // Do we have some shipyards?
+ if (is_null($this->shipyardList)) {
+ // No shipyards created
+ throw new NoShipyardsConstructedException($this, self::EXCEPTION_HARBOR_HAS_NO_SHIPYARDS);
+ }
+
+ // Get iterator for shipyards
+ $shipyardIter = $this->shipyardList->getIterator();
+
+ // Iterate through all employees
+ for ($idx = $this->employeeList->getIterator(); $idx->valid(); $idx->next()) {
+ // Is the shipyard iterator still okay?
+ if (!$shipyardIter->valid()) {
+ // Rewind to first position
+ $shipyardIter->seek(0);
+ }
+
+ // Get Shipyard object
+ $shipyard = $shipyardIter->current();
+
+ // Is this a Shipyard object?
+ if (is_null($shipyard)) {
+ // No class returned
+ 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->isClass("Shipyard")) {
+ // Nope, so throw exception
+ throw new ClassMismatchException(array($shipyard->__toString(), "Shipyard"), self::EXCEPTION_CLASSES_NOT_MATCHING);
+ }
+
+ // Add employee to the shipyard
+ $shipyard->addNewPersonell($idx->current());
+
+ // Continue to next shipyard
+ $shipyardIter->next();
+ }
+ }
+
+ // Getter for total employees
+ public function getTotalEmployee () {
+ // Count all...
+ $total = $this->employeeList->count();
+
+ // Debug message
+ if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> hat <strong>%d</strong> Mitarbeiter.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $total
+ ));
+
+ // Return amount
+ return $total;
+ }
+
+ // Getter for total shipyards
+ public function getTotalShipyards () {
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Für die Reederei <strong>%s</strong> werden die Anzahl der Werften in allen Häfen ermittelt.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName()
+ ));
+
+ // Do we have some shipyards?
+ if (is_null($this->shipyardList)) {
+ // No shipyards created
+ throw new NoShipyardsConstructedException($this, self::EXCEPTION_HARBOR_HAS_NO_SHIPYARDS);
+ }
+
+ // Get iterator
+ $total = $this->shipyardList->count();
+
+ // Debug message
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> hat <strong>%d</strong> Werft(en).<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $total
+ ));
+
+ // Return amount
+ return $total;
+ }
+
+ // Add a ship type (class) to all shipyards
+ public function addShipTypeToAllShipyards ($shipType) {
+ // Secure strings
+ $shipType = (string) $shipType;
+
+ // Is the class there?
+ if (!class_exists($shipType)) {
+ // Throw exception
+ throw new ClassNotFoundException($shipType, 0);
+ }
+
+ // Create dummy ship
+ eval(sprintf("\$shipInstance = %s::create%s(\"M/S Dummy\");",
+ $shipType,
+ $shipType
+ ));
+
+ // Debug message
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> baut in allen Werften bald Schiffe vom Typ <strong>%s</strong>.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $shipInstance->getPartDescr()
+ ));
+
+ // Iterate shipyard list
+ for ($idx = $this->shipyardList->getIterator(); $idx->valid(); $idx->next()) {
+ // Get current element
+ $shipyard = $idx->current();
+
+ // Is this a shipyard?
+ if (is_null($shipyard)) {
+ // Opps! Empty list?
+ 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->isClass("Shipyard")) {
+ // 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);
+ }
+ }
+
+ // Validate the requested ship type with the company if they can construct it
+ public function validateWorksContractShipType (WorksContract $contractInstance) {
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> prüft den Bauauftrag der <strong>%s</strong>.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $contractInstance->getShipName()
+ ));
+
+ // First get the ship type
+ $shipInstance = $contractInstance->getShipInstance();
+
+ // Ist there a ship instance?
+ if (is_null($shipInstance)) {
+ // Opps! Empty entry?
+ 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);
+ }
+
+ // 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 <strong>%s</strong> prüft, ob die <strong>%s</strong> (Typ:<strong>%s</strong>) gebaut werden kann.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $contractInstance->getShipName(),
+ $shipInstance->getPartDescr()
+ ));
+
+ // Now check if the ship type is in any list and return the result
+ return ($this->isShipTypeConstructable($shipType));
+ }
+
+ // Is the ship type constructable?
+ public function isShipTypeConstructable ($shipType) {
+ // The type must be a string!
+ $shipType = (string) $shipType;
+
+ // Debug message
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> fragt alle Werften ab, ob diese Schiffe vom Typ <strong>%s</strong> bauen können.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $shipType
+ ));
+
+ // First everthing is failed...
+ $result = false;
+
+ // Iterate through all shipyards
+ for ($idx = $this->shipyardList->getIterator(); $idx->valid(); $idx->next()) {
+ // Get current Shipyard instance
+ $shipyard = $idx->current();
+
+ // Is this a shipyard?
+ if (is_null($shipyard)) {
+ // Opps! Empty list?
+ 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->isClass("Shipyard")) {
+ // 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
+ $result = $shipyard->isShipTypeConstructable($shipType);
+
+ // Does this shipyard construct the requested ship type?
+ if ($result) break; // Then abort the search!
+ }
+
+ // Debug message
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> hat die Suche nach einer Werft beendet, die Schiffe vom Typ <strong>%s</strong> bauen kann.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $shipType
+ ));
+
+ // Return result
+ return $result;
+ }
+
+ // As a customer the shipping company can add new contracts
+ public function addNewWorksContract (WorksContract $contractInstance) {
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> erstellt einen Bauauftrag für ein <strong>%s</strong> mit dem Namen <strong>%s</strong>.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $contractInstance->getShipInstance()->getPartDescr(),
+ $contractInstance->getShipInstance()->getShipName()
+ ));
+ $this->contractList->append($contractInstance);
+ }
+
+ // As a customer the shippng company can withdraw from a contract
+ public function withdrawFromContract (WorksContract $contractInstance) {
+ ApplicationEntryPoint::app_die("WITHDRAW:<pre>".print_r($contractInstance, true)."</pre>");
+ }
+
+ // Get latest added contract instance
+ public function getLastContractInstance () {
+ // Get iterator
+ $iter = $this->contractList->getIterator();
+
+ // Get latest entry (total - 1)
+ $iter->seek($iter->count() - 1);
+
+ // Return entry
+ return $iter->current();
+ }
+
+ // Sign a contract with an other party which must also implement Customer
+ public function signContract (WorksContract $contractInstance, ContractPartner $partnerInstance) {
+ if (!$partnerInstance->isContractPartner($contractInstance)) {
+ // Invalid contract partner!
+ throw new InvalidContractPartnerException($partnerInstance, self::EXCEPTION_CONTRACT_PARTNER_INVALID);
+ }
+
+ // 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 <strong>%s</strong> erteilt an sich selbst einen Bauauftrag für das <strong>%s</strong> "<strong>%s</strong>".<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $contractInstance->getShipInstance()->getPartDescr(),
+ $contractInstance->getShipInstance()->getShipName()
+ ));
+ } else {
+ // Other external company
+ if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> unterzeichnet einen Bauauftrag für das <strong>%s</strong> "<strong>%s</strong>" mit der <strong>%s</strong>.<br />\n",
+ __CLASS__,
+ __LINE__,
+ $this->getCompanyName(),
+ $contractInstance->getShipInstance()->getPartDescr(),
+ $contractInstance->getShipInstance()->getShipName(),
+ $partnerInstance->getCompanyName()
+ ));
+ }
+
+ // Sign the contract
+ $contractInstance->signContract($this, $partnerInstance);
+
+ /**
+ * @todo Maybe do something more here...
+ */
+ }
+
+ // Is this the right contract partner?
+ public function isContractPartner (WorksContract $contractInstance) {
+ // Get contract partner instance and compare it with $this contract partner
+ return ($this->equals($contractInstance->getContractPartner()));
+ }
+
+ // Setter for merchant instance
+ public function setMerchantInstance (Merchant $merchantInstance) {
+ // Get contract
+ $contractInstance = $this->getLastContractInstance();
+
+ if (is_null($contractInstance)) {
+ // Opps! Empty contract instance?
+ 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->isClass('WorksContract')) {
+ // Is not a merchant
+ throw new ClassMismatchException(array($contractInstance->__toString(), "WorksContract"), self::EXCEPTION_CLASSES_NOT_MATCHING);
+ }
+
+ // Set the merchant in the contract (for getting prices)
+ $contractInstance->setMerchantInstance($merchantInstance);
+ }
+
+ /**
+ * Stub!
+ */
+ public function saveObjectToDatabase () {
+ $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
+ $this->__toString(),
+ __FUNCTION__
+ ));
+ }
+
+ /**
+ * Limits this object with an ObjectLimits instance
+ */
+ public function limitObject (ObjectLimits $limitInstance) {
+ ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
+ }
+}
+
+// [EOF]
+?>