Browse Source

refactoring: reduce code in print_guess_word_question

main
parent
commit
9c7fc2c713
  1. 44
      src/main/quizproject.c

44
src/main/quizproject.c

@ -357,9 +357,15 @@ void hint_anagram(int hint_num) {
"o_e__t_on",
"p_p_la__on",
"p__g__ss",
"c_a__en_e",
"e_ce__en_e",
"al_o_ati__"
"r__pon__ven__s",
"char__te___tic",
"Int__lig__tly",
"unc__st_t_t_o_al",
"inco_pr_h_ns__le",
"env__on__nta__sm",
"unp__fess__nali__",
"mu__ic_lt_ra__sm",
"co__ter__l__ce"
};
printf("Here is your hint: %s\n",hint_questions[hint_num]);
}
@ -472,6 +478,8 @@ bool e_true_false(char choice) {
return true;
} else if(choice == 'F') {
return false;
} else {
return -1;
}
}
@ -605,13 +613,8 @@ void print_guess_word_question (char guessWord[][100], char guessSolution[][100]
scanf("%s",usr_ans);
char arr[30];
for(int p = 0; p < 30; p++) {
for(int p = 0; p < 15; p++) {
arr[p] = guessSolution[runNum][p];
if (guessSolution[runNum][p] == '\0') {
break;
}
}
@ -622,7 +625,7 @@ void print_guess_word_question (char guessWord[][100], char guessSolution[][100]
}
}
if (k == strlen(arr) && strlen(usr_ans) == strlen(arr)) {
if (k == strlen(arr)) {
score++;
correct(score);
printf("You guessed right! The word is rightfully, %s!\n\n", guessedWord[runNum]);
@ -686,13 +689,22 @@ void e_anagram_questions() {
"pilgrimage",
"operation",
"population",
"progress"
"progress",
"responsiveness",
"characteristic",
"Intelligently",
"unconstitutional",
"incomprehensible",
"environmentalism",
"unprofessionalism",
"multiculturalism",
"counterbalance"
};
char print_questions[100][100];
int *charNum = randomNumber();
char arr[100];
for (int i = 0; i < 6; i++) {
for (int i = 0; i < 15; i++) {
for(int j = 0; j < 100; j++) {
arr[j] = questions[i][j];
if (questions[i][j] == '\0') {
@ -721,7 +733,7 @@ void e_anagram_questions() {
int charArr2[6];
int p1 = 0;
for(int l = 0; l < 100; l++) {
if (charNum[l] < 6) {
if (charNum[l] < 15) {
charArr2[p1] = charNum[l];
p1++;
}
@ -802,9 +814,9 @@ void math_solution(char math_solutions[][10], int init1){
if(strlen(fact_answer) == k){
score++;
printf("right! your score: %d\n", score);
correct(score);
}else {
printf("worng! your score: %d\n", score);
wrong(score);
}
}
@ -3376,7 +3388,7 @@ void v_progress_bar(int argc, char *argv[]){
int main(int argc, char *argv[]) {
int choice;
printf("Welcome to the Game Menu!\n");
printf("\t\t Welcome to the Game Menu!\n");
printf("\t\t----------------------------\n\n");
printf("\t\t----------------------------\n\n");
printf("\t\t Welcome! \n\n");

Loading…
Cancel
Save