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.

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

61 ∗ the other methods .<br />

62 ∗/<br />

63 virtual void turnCard ( )<br />

64 {<br />

65 v i s i b l e s i d e = ( v i s i b l e s i d e == FRONT SIDE) ?<br />

66 BACK SIDE : FRONT SIDE;<br />

67 }<br />

68<br />

69 /∗ Puts the f r o n t s i d e of the card up ( i . e . makes i t v i s i b l e ) ,<br />

70 ∗ r e g a r d l e s s of which s i d e i s v i s i b l e at the moment .<br />

71 ∗/<br />

72 virtual void putFrontSideUp ( )<br />

73 {<br />

74 v i s i b l e s i d e = FRONT SIDE;<br />

75 }<br />

76<br />

77 /∗ Puts the back s i d e of the card up ( i . e . makes i t v i s i b l e ) ,<br />

78 ∗ r e g a r d l e s s of which s i d e i s v i s i b l e at the moment .<br />

79 ∗/<br />

80 virtual void putBackSideUp ( )<br />

81 {<br />

82 v i s i b l e s i d e = BACK SIDE;<br />

83 }<br />

84<br />

85 /∗ Returns the v i s i b l e s i d e of the card .<br />

86 ∗ @return The v i s i b l e s i d e of the card <strong>in</strong> the form o f one o f<br />

87 ∗ the two constants FRONT SIDE or BACK SIDE.<br />

88 ∗/<br />

89 virtual u<strong>in</strong>t8 g e t V i s i b l e S i d e ( )<br />

90 {<br />

91 return ( v i s i b l e s i d e ) ;<br />

92 }<br />

93 } ;<br />

94<br />

95<br />

96 #endif // game card v3 h<br />

10.2.14 MemoryGameCard<br />

Die Klasse MemoryGameCard ist ebenfalls e<strong>in</strong>e weitere kle<strong>in</strong>e Variation der im<br />

letzten Kapitel besprochenen Memory Spielkarten. Sie ist e<strong>in</strong>e e<strong>in</strong>fache, darstellbare<br />

Spielkarte. Als solche ist sie von Displayable und von GameCard<br />

abgeleitet und speichert e<strong>in</strong> Symbol für die Vorderseite und e<strong>in</strong> Symbol für<br />

die Rückseite. Nachdem die Karte ke<strong>in</strong>e Kristallkugel befragen kann, welches<br />

Symbol sie für die Vorder- und welches für die Rückseite speichern soll,<br />

müssen diese beiden von außen gesetzt werden. Dies muss natürlich im Konstruktor<br />

geschehen, denn es muss ja verh<strong>in</strong>dert werden, dass jemand schummelt,<br />

<strong>in</strong>dem e<strong>in</strong>fach das Symbol umgesetzt wird :-). Dieses Meisterwerk hat<br />

dann die folgende Form:<br />

1 // memory game card v5 . h − memory game card as used <strong>in</strong> the example<br />

2<br />

3 #ifndef memory game card v5 h<br />

4 #def<strong>in</strong>e memory game card v5 h<br />

5<br />

6 #<strong>in</strong>clude ”game card v3 . h”<br />

7 #<strong>in</strong>clude ” s i m p l e 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!