getter, setter are all final; several code clean-ups
[shipsimu.git] / application / ship-simu / main / structures / extended / class_BaseDeckStructure.php
1 <?php
2 // Decks (fuer Cargo) allgemein
3 class BaseDeckStructure extends BaseStructure {
4         // Anzahl Decks
5         private $numDecks = 0;
6
7         // Konstruktor
8         private function __construct ($class) {
9                 // Call parent constructor
10                 parent::constructor($class);
11
12                 // Debug message
13                 if (((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
14                         $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
15                                 __CLASS__,
16                                 __LINE__
17                         ));
18                 }
19
20                 // Set description
21                 $this->setPartDescr("Deckstruktur");
22         }
23
24         /**
25          * Calls the private constructor
26          *
27          * @param       $class  The class' name
28          * @return      void
29          */
30         public function constructor ($class) {
31                 $this->__construct($class);
32         }
33
34         // Deckstruktur dem Schiff hinzufuegen
35         public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $deckInstance) {
36                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Deck <strong>%s</strong> wird f&uuml;r das Schiff <strong>%s</strong> konstruiert.<br />\n",
37                         __CLASS__,
38                         __LINE__,
39                         $deckInstance->getPartDescr(),
40                         $shipInstance->getShipName()
41                 ));
42
43                 // Eltern-Methode aufrufen
44                 parent::addShipPartToShip($shipInstance, $deckInstance);
45
46                 // Andere Daten uebertragen und von der Quelle loeschen
47                 $this->setNumDecks($deckInstance->getNumDecks());
48                 $deckInstance->removeNumDecks();
49
50                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Deck <strong>%s</strong> wurde in das Schiff <strong>%s</strong> eingebaut.<br />\n",
51                         __CLASS__,
52                         __LINE__,
53                         $deckInstance->getPartDescr(),
54                         $shipInstance->getShipName()
55                 ));
56         }
57
58         // Deckanzahl entfernen
59         public function removeNumDecks() {
60                 if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Anzahl Decks wurde gel&ouml;scht.<br />\n",
61                         __CLASS__,
62                         __LINE__
63                 ));
64                 unset($this->numDecks);
65         }
66
67         // Setter-Methode fuer Anzahl Decks
68         public final function setNumDecks($numDecks) {
69                 $this->numDecks = (int) $numDecks;
70         }
71
72         // Getter-Methode fuer Anzahl Decks
73         public final function getNumDecks() {
74                 return $this->numDecks;
75         }
76 }
77
78 // [EOF]
79 ?>