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.

304 10. Memory – e<strong>in</strong> kle<strong>in</strong>es Beispiel<br />

84 ∗ are used to s t o r e which cards are s e t<br />

85 ∗/<br />

86 virtual u<strong>in</strong>t8 whichCardsAreSet ( )<br />

87 {<br />

88 return ( c a r d s e t s t a t u s & CARD SET BITS ) ;<br />

89 }<br />

90<br />

91 /∗ Returns , whether both cards were i n i t i a l l y l y i n g on the f i e l d<br />

92 ∗ with t h e i r back s i d e s up<br />

93 ∗ @return true i f both cards were i n i t i a l l y hidden , f a l s e<br />

94 ∗ otherwise<br />

95 ∗/<br />

96 virtual bool wereBothCardsBackSideUp ( )<br />

97 {<br />

98 return ( ( c a r d s e t s t a t u s & CARD TURN BITS) ==<br />

99 CARD TURN BITS) ;<br />

100 }<br />

101<br />

102 /∗ Returns , whether the symbols o f the two cards are match<strong>in</strong>g .<br />

103 ∗ I f not both cards were already s e l e c t e d , the method returns<br />

104 ∗ f a l s e ( j u s t because exceptions are not known yet ) .<br />

105 ∗ @param gameboard The gameboard to work on<br />

106 ∗ @return true i f the symbols are match<strong>in</strong>g , f a l s e otherwise<br />

107 ∗/<br />

108 virtual bool cardSymbolsMatch<strong>in</strong>g (<br />

109 MemoryGameboard &gameboard ) ;<br />

110<br />

111 /∗ Undo . . . r e s t o r e s the o r i g i n a l v i s i b l e s t a t e o f each o f the<br />

112 ∗ two cards<br />

113 ∗ @param gameboard The gameboard to work on .<br />

114 ∗/<br />

115 virtual void turnCardsBackToTheirOrig<strong>in</strong>alState (<br />

116 MemoryGameboard &gameboard ) ;<br />

117<br />

118 /∗ Clears a l l the s t a t u s f i e l d s o f t h i s i n s t a n c e<br />

119 ∗/<br />

120 virtual void c l e a r ( ) ;<br />

121 } ;<br />

122<br />

123<br />

124 #endif // memory cardpair h<br />

10.3 Auszüge aus der Implementation<br />

Um das Verständnis für die Zusammenhänge und die Abläufe im Spiel etwas<br />

zu vertiefen, möchte ich an dieser Stelle noch e<strong>in</strong>e paar Auszüge aus den<br />

Implementationen der Klassen ganz kurz besprechen. Der vollständige Code<br />

ist <strong>in</strong> Anhang B zu f<strong>in</strong>den.<br />

Am schnellsten kommt man durch e<strong>in</strong>en kurzen Blick auf das Hauptprogramm<br />

zum tieferen Verständnis:<br />

1 //memory ma<strong>in</strong> . cpp − ma<strong>in</strong> program that s t a r t s memory<br />

2<br />

3 #<strong>in</strong>clude <br />

4<br />

5 #<strong>in</strong>clude ” simple commandl<strong>in</strong>e handl<strong>in</strong>g . h”<br />

6 #<strong>in</strong>clude ”memory commandl<strong>in</strong>e arg handler . h”<br />

7 #<strong>in</strong>clude ”memory gameboard . h”

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

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!