@@ -15,6 +15,7 @@ int main() {
15
15
int cols = COLS ;
16
16
int cellAlive = 0 ;
17
17
int cellDead = 0 ;
18
+ int invalidPattern ;
18
19
19
20
char * requestedPattern ;
20
21
@@ -25,10 +26,31 @@ int main() {
25
26
game .cellsDead = cellDead ;
26
27
27
28
fillDashboard (& game , 0 );
28
- requestedPattern = getUserInputStr (
29
+
30
+ do {
31
+ requestedPattern = getUserInputStr (
29
32
"> Which pattern do you want "
30
33
"('Glider','Toad', 'Press', or 'Glider cannon')? " ,
31
34
"> Invalid pattern! Try again..." , 50 , & validatePattern );
32
- printf ("> Pattern received: '%s'" , requestedPattern );
35
+ printf ("> Pattern received: '%s'" , requestedPattern );
36
+
37
+ invalidPattern = 0 ;
38
+
39
+ if (strcmpi (requestedPattern ,"GLIDER" ) == 0 )
40
+ gliderPattern (dashboard );
41
+ else if (strcmpi (requestedPattern ,"TOAD" ) == 0 )
42
+ toadPattern (dashboard );
43
+ else if (strcmpi (requestedPattern ,"PRESS" ) == 0 )
44
+ pressPattern (dashboard );
45
+ else if (strcmpi (requestedPattern ,"GLIDER CANNON" ) == 0 )
46
+ gliderCannonPattern (dashboard );
47
+ else {
48
+ puts ("INVALID PATTERN, try again... :" );
49
+ invalidPattern = 1 ;
50
+ }
51
+
52
+ }while (invalidPattern );
53
+
54
+
33
55
return 0 ;
34
56
}
0 commit comments