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.

B.1 Implementationen der e<strong>in</strong>zelnen Klassen 549<br />

21 {<br />

22 i f ( ( num rows ∗ num cols ) % 2) // not an even number<br />

23 num rows ++;<br />

24<br />

25 row vector = new Vector ( num rows ,<br />

26 VectorDeletor : : getInstance ( ) ) ;<br />

27 for ( u<strong>in</strong>t32 current row = 0 ; current row < num rows ;<br />

28 current row ++)<br />

29 row vector −>setElementAt (<br />

30 current row ,new Vector ( num cols ,<br />

31 DisplayableDeletor : : getInstance ( ) ) ) ;<br />

32 }<br />

33<br />

34 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−<br />

35 MemoryGameboard : : ˜ MemoryGameboard ( )<br />

36 {<br />

37 // no need to d e l e t e any d i s p l a y a b l e s r e g i s t e r e d with<br />

38 // i t , because they are a l l stored <strong>in</strong> our v e c t o r s<br />

39 // and deleted from there<br />

40 delete conta<strong>in</strong>er output handl<strong>in</strong>g ;<br />

41<br />

42 // t h i s a l s o d e l e t e s a l l the column v e c t o r s which <strong>in</strong><br />

43 // turn d e l e t e a l l the cards .<br />

44 delete row vector ;<br />

45<br />

46 // t h i s a l s o d e l e t e s a l l the head<strong>in</strong>g d i s p l a y a b l e s<br />

47 delete r o w h e a d i n g d i s p l a y a b l e s ;<br />

48<br />

49 // t h i s a l s o d e l e t e s a l l the head<strong>in</strong>g d i s p l a y a b l e s<br />

50 delete c o l h e a d i n g d i s p l a y a b l e s ;<br />

51<br />

52 // t h i s a l s o d e l e t e s a l l the e o l d i s p l a y a b l e s<br />

53 delete e o l d i s p l a y a b l e s ;<br />

54<br />

55 delete c o n t a i n e r o u t p u t c o n t e x t ;<br />

56 }<br />

57<br />

58 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−<br />

59 void MemoryGameboard : : d i s p l a y a b l e R e g i s t e r e d (<br />

60 SimpleOutputHandl<strong>in</strong>g &handler )<br />

61 {<br />

62 // already r e g i s t e r e d with some handler , no f u r t h e r<br />

63 // setup necessary<br />

64 i f ( r o w h e a d i n g d i s p l a y a b l e s )<br />

65 return ;<br />

66<br />

67 u<strong>in</strong>t32 num displayables = ( num rows ∗ num cols ) + // cards<br />

68 num rows + 1 + // EOL elements<br />

69 num rows + 1 + // c o l head<strong>in</strong>gs<br />

70 num cols ; // row head<strong>in</strong>gs<br />

71 r o w h e a d i n g d i s p l a y a b l e s = new Vector (<br />

72 num cols , DisplayableDeletor : : getInstance ( ) ) ;<br />

73 c o l h e a d i n g d i s p l a y a b l e s = new Vector (<br />

74 num rows + 1, DisplayableDeletor : : getInstance ( ) ) ;<br />

75 e o l d i s p l a y a b l e s = new Vector (<br />

76 num rows + 1, DisplayableDeletor : : getInstance ( ) ) ;<br />

77 c o n t a i n e r o u t p u t c o n t e x t = handler . getOutputContextClone ( ) ;<br />

78 conta<strong>in</strong>er output handl<strong>in</strong>g = new SimpleOutputHandl<strong>in</strong>g (<br />

79 num displayables , ∗ c o n t a i n e r o u t p u t c o n t e x t ) ;<br />

80<br />

81 // j u s t because some compilers have a wrong treatment f o r<br />

82 // v a r i a b l e s <strong>in</strong> c o n t r o l statements . . .<br />

83 u<strong>in</strong>t32 row count = 0;<br />

84 u<strong>in</strong>t32 col count = 0;<br />

85<br />

86 // generate the top l i n e with the column head<strong>in</strong>gs and

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

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!