Skip to content

Commit 2b25ae5

Browse files
author
Guidolinares
committed
functions pattern
1 parent 55826eb commit 2b25ae5

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/main.c

+24-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ int main() {
1515
int cols = COLS;
1616
int cellAlive = 0;
1717
int cellDead = 0;
18+
int invalidPattern;
1819

1920
char* requestedPattern;
2021

@@ -25,10 +26,31 @@ int main() {
2526
game.cellsDead = cellDead;
2627

2728
fillDashboard(&game, 0);
28-
requestedPattern = getUserInputStr(
29+
30+
do{
31+
requestedPattern = getUserInputStr(
2932
"> Which pattern do you want "
3033
"('Glider','Toad', 'Press', or 'Glider cannon')? ",
3134
"> 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+
3355
return 0;
3456
}

0 commit comments

Comments
 (0)