30.06.2013 Aufrufe

Softwareentwicklung in C++ - ASC

Softwareentwicklung in C++ - ASC

Softwareentwicklung in C++ - ASC

MEHR ANZEIGEN
WENIGER ANZEIGEN

Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.

YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.

225<br />

10.2 Das DDD 289<br />

226 /∗ Returns the number of cards that c u r r e n t l y are l y i n g on the<br />

227 ∗ board with t h e i r back s i d e s up .<br />

228 ∗ @return The actual number of cards that show t h e i r back s i d e s<br />

229 ∗/<br />

230 virtual u<strong>in</strong>t32 getNumCardsBackSideUp ( ) const<br />

231 {<br />

232 return ( ( num rows ∗ num cols ) − num cards front side up ) ;<br />

233 }<br />

234<br />

235 /∗ This method i s c a l l e d to put a card on the board . I f a card<br />

236 ∗ already occupies the d e s i r e d place t h i s c a l l i s ignored .<br />

237 ∗ Please note that the card has to be deleted then , because<br />

238 ∗ the c a l l e r s r e l y on t h i s f a c t ! ( j u s t because exceptions are<br />

239 ∗ not known yet )<br />

240 ∗ A range−check has to be performed on the coord<strong>in</strong>ates . I f they<br />

241 ∗ are out of range the c a l l i s ignored and the card i s deleted ,<br />

242 ∗ because c a l l e r s r e l y on t h i s f a c t ! ( j u s t because exceptions<br />

243 ∗ are not known yet )<br />

244 ∗ @param card A po<strong>in</strong>ter to the card that has to be put on the<br />

245 ∗ board . The card w i l l be deleted <strong>in</strong> the d e s t r u c t o r !<br />

246 ∗ @param row The row , where the card has to be put .<br />

247 ∗ @param c o l The column , where the card has to be put .<br />

248 ∗/<br />

249 virtual void putCardOnBoard (MemoryGameCard ∗ card ,<br />

250 u<strong>in</strong>t32 row , u<strong>in</strong>t32 c o l ) ;<br />

251 protected :<br />

252 /∗ An i n t e r n a l convenience method used to obta<strong>in</strong> a card . I t<br />

253 ∗ does not perform any checks because i t assumes that they<br />

254 ∗ have already been performed before .<br />

255 ∗ @param row The row of the d e s i r e d card .<br />

256 ∗ @param c o l The column of the d e s i r e d card .<br />

257 ∗/<br />

258 MemoryGameCard ∗ <strong>in</strong>ternalGetCard ( u<strong>in</strong>t32 row , u<strong>in</strong>t32 c o l ) const<br />

259 {<br />

260 return ( static cast(<br />

261 static cast(<br />

262 row vector −>getElementAt ( row))−>getElementAt ( c o l ) ) ) ;<br />

263 }<br />

264 } ;<br />

265<br />

266<br />

267 #endif // memory gameboard h<br />

Dass es e<strong>in</strong>en Vektor für die e<strong>in</strong>zelnen Displayables der Reihenköpfe (Zeile<br />

56) und Spaltenköpfe (Zeile 62) gibt, ist ja zu erwarten. Was aber soll im<br />

Vektor <strong>in</strong> Zeile 69 bloß gehalten werden? Ganz e<strong>in</strong>fach: Die Displayables, die<br />

nach jeder Spielfeldzeile den Zeilenumbruch bewirken! Ansonsten wäre das<br />

Spielfeld ja ziemlich lang und flach :-).<br />

10.2.16 IntDisplayable<br />

Die Klasse IntDisplayable, die hier vorgestellt wird, braucht eigentlich ke<strong>in</strong>e<br />

besondere Erklärung:<br />

1 // s i m p l e i n t d i s p l a y a b l e . h − a d i s p l a y a b l e f o r i n t e g r a l numbers<br />

2<br />

3 #ifndef s i m p l e i n t d i s p l a y a b l e h<br />

4 #def<strong>in</strong>e s i m p l e i n t d i s p l a y a b l e h

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!