@@ -54,7 +54,7 @@ class D_Defense {
5454 * @param int $dinterplanetary_missile
5555 */
5656 public function __construct (
57- int $ drocket_launcher , int $ dlight_laser , int $ dheavy_laser , int $ dion_cannon , int $ dgauss_cannon ,
57+ int $ drocket_launcher , int $ dlight_laser , int $ dheavy_laser , int $ dgauss_cannon , int $ dion_cannon ,
5858 int $ dplasma_turret , int $ dsmall_shield_dome ,
5959 int $ dlarge_shield_dome , int $ danti_ballistic_missile , int $ dinterplanetary_missile
6060 ) {
@@ -81,47 +81,6 @@ public function print() : void {
8181 echo '</pre> ' ;
8282 }
8383
84- /**
85- * Return the level of the defense, given its id
86- * @param int $id the defense id
87- * @return int the level of the defense
88- */
89- public function getDefenseByID (int $ id ) : int {
90-
91- switch ($ id ) {
92- case 301 :
93- $ this ->getRocketLauncher ();
94- break ;
95- case 302 :
96- $ this ->getLightLaser ();
97- break ;
98- case 303 :
99- $ this ->getHeavyLaser ();
100- break ;
101- case 304 :
102- $ this ->getGaussCannon ();
103- break ;
104- case 305 :
105- $ this ->getIonCannon ();
106- break ;
107- case 306 :
108- $ this ->getPlasmaTurret ();
109- break ;
110- case 307 :
111- $ this ->getSmallShieldDome ();
112- break ;
113- case 308 :
114- $ this ->getLargeShieldDome ();
115- break ;
116- case 309 :
117- $ this ->getAntiBallisticMissile ();
118- break ;
119- case 310 :
120- $ this ->getInterplanetaryMissile ();
121- break ;
122- }
123- }
124-
12584 /**
12685 * Returns the current amount
12786 * @return int the current amount
@@ -182,42 +141,42 @@ public function setHeavyLaser(int $amount) : void {
182141 }
183142
184143 /**
185- * Returns the current amount
144+ * Returns the current amount amount
186145 * @return int the current amount
187146 */
188- public function getGaussCannon () : int {
147+ public function getIonCannon () : int {
189148
190- return $ this ->gauss_cannon ;
149+ return $ this ->ion_cannon ;
191150 }
192151
193152 /**
194153 * Sets the current amount
195- * @param int $gauss_cannon the new amount
154+ * @param int $ion_cannon the new amount
196155 */
197- public function setGaussCannon (int $ amount ) : void {
156+ public function setIonCannon (int $ amount ) : void {
198157
199158 if ($ amount >= 0 ) {
200- $ this ->gauss_cannon = $ amount ;
159+ $ this ->ion_cannon = $ amount ;
201160 }
202161 }
203162
204163 /**
205- * Returns the current amount amount
164+ * Returns the current amount
206165 * @return int the current amount
207166 */
208- public function getIonCannon () : int {
167+ public function getGaussCannon () : int {
209168
210- return $ this ->ion_cannon ;
169+ return $ this ->gauss_cannon ;
211170 }
212171
213172 /**
214173 * Sets the current amount
215- * @param int $ion_cannon the new amount
174+ * @param int $gauss_cannon the new amount
216175 */
217- public function setIonCannon (int $ amount ) : void {
176+ public function setGaussCannon (int $ amount ) : void {
218177
219178 if ($ amount >= 0 ) {
220- $ this ->ion_cannon = $ amount ;
179+ $ this ->gauss_cannon = $ amount ;
221180 }
222181 }
223182
@@ -321,6 +280,50 @@ public function setInterplanetaryMissile(int $amount) : void {
321280 }
322281 }
323282
283+ /**
284+ * Return the level of the defense, given its id
285+ * @param int $id the defense id
286+ * @return int the level of the defense
287+ */
288+ public function getDefenseByID (int $ id ) : int {
289+
290+ switch ($ id ) {
291+ case 301 :
292+ return $ this ->getRocketLauncher ();
293+ break ;
294+ case 302 :
295+ return $ this ->getLightLaser ();
296+ break ;
297+ case 303 :
298+ return $ this ->getHeavyLaser ();
299+ break ;
300+ case 304 :
301+ return $ this ->getGaussCannon ();
302+ break ;
303+ case 305 :
304+ return $ this ->getIonCannon ();
305+ break ;
306+ case 306 :
307+ return $ this ->getPlasmaTurret ();
308+ break ;
309+ case 307 :
310+ return $ this ->getSmallShieldDome ();
311+ break ;
312+ case 308 :
313+ return $ this ->getLargeShieldDome ();
314+ break ;
315+ case 309 :
316+ return $ this ->getAntiBallisticMissile ();
317+ break ;
318+ case 310 :
319+ return $ this ->getInterplanetaryMissile ();
320+ break ;
321+ }
322+
323+ return -1 ;
324+
325+ }
326+
324327 /**
325328 * Sets the level of the defense, given its id and new level
326329 * @param int $id the id of the defense
0 commit comments