diff --git a/src/main/quizproject.c b/src/main/quizproject.c index 0b4b874..04b09be 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -4,7 +4,7 @@ #include #include #include "quizproject.h" - +char answers[NUM_QUESTIONS] = {'B', 'A'}; int* randomNumber() { srand(time(NULL)); @@ -109,14 +109,21 @@ void fifty_fifty(int question_num) { printf("%s\n",qC[question_num]); } +void hintForHardQuestions(int question_num) { + char hints[NUM_QUESTIONS][256] = { + "The city is known for its iconic landmarks and romantic atmosphere.", + "He was a general in the American Revolutionary War and is considered the Father of His Country.", + "This team has won the most NBA championships in history, with a total of 16 championships." + }; + printf("Hint: %s\n", hints[question_num]); +} + void fifty_fifty1(int question_num) { char options[NUM_QUESTIONS][4][256] = { { "A) Berlin", "B) Paris", "C) London", "D) Rome" }, { "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" }, - { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" }, - { "A) He", "B) H", "C) O", "D) Ne" }, - { "A) Parasite", "B) Joker", "C) Once Upon a Time in Hollywood", "D) 1917" } - }; + { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" } + }; char correct_answer = answers[question_num]; int num_incorrect = 0; int incorrect_indices[2]; @@ -282,16 +289,18 @@ void ask_hard_questions(void) { char questions[NUM_QUESTIONS][256] = { - "Which author is famed for her detective novels about Hercule Poirot and Miss Marple?", - "Atticus Finch is one of the main characters in which novel from 1960?" + "What is the capital of France?", + "Who was the first president of the United States?", + "Which team won the most NBA championships?", }; char options[NUM_QUESTIONS][4][256] = { - { "A) Arthur Conan Doyle", "B) Agatha Christie", "C) Charles Dickens", "D) Stephen King" }, - { "A) To Kill a Mockingbird", "B) Pride and Prejudice", "C) The Great Gatsby", "D) Jane Eyre" } + { "A) Berlin", "B) Paris", "C) London", "D) Rome" }, + { "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" }, + { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" } }; char user_answers[NUM_QUESTIONS]; - int lifelines[NUM_QUESTIONS] = { 1, 1}; + int lifelines[NUM_QUESTIONS] = { 1, 1,1,1}; int randNum; for (int i = 0; i < 2; i++) { randNum = arr[i]; @@ -299,7 +308,7 @@ void ask_hard_questions(void) { for (int j = 0; j < 4; j++) { printf("%s\n", options[randNum][j]); } - printf("Enter your answer (A, B, C, or D): "); + printf("Enter your answer (A, B, C, or D) or use a lifeline (F for 50/50, H for hint): "); char response; scanf(" %c", &response); response = toupper(response); @@ -309,8 +318,13 @@ void ask_hard_questions(void) { scanf(" %c", &user_answers[randNum]); user_answers[randNum] = toupper(user_answers[randNum]); lifelines[i] = 0; - } - else { + }else if (response == 'H' && lifelines[i] == 1) { + hintForHardQuestions(randNum); + printf("Enter your answer (A, B, C, or D): "); + scanf(" %c", &user_answers[randNum]); + user_answers[randNum] = toupper(user_answers[randNum]); + lifelines[i] = 0; + }else { user_answers[randNum] = response; } if (user_answers[randNum] == answers[randNum]) { @@ -326,14 +340,14 @@ void ask_hard_questions(void) { } else { printf("\t\t--------------------Round 5-------------------\n\n"); printf(">>This is the final round. Good Luck!<<\n\n"); - for (int i = 0; i < 2; i++) { + for (int i = 2; i < 3; i++) { randNum = arr[i]; printf("[%d] %s\n", i + 1, questions[randNum]); for (int j = 0; j < 4; j++) { printf("%s\n", options[randNum][j]); } - printf("Enter your answer (A, B, C, or D): "); + printf("Enter your answer (A, B, C, or D) or use a lifeline (F for 50/50, H for hint): "); char response; scanf(" %c", &response); response = toupper(response); @@ -343,8 +357,13 @@ void ask_hard_questions(void) { scanf(" %c", &user_answers[randNum]); user_answers[randNum] = toupper(user_answers[randNum]); lifelines[i] = 0; - } - else { + }else if (response == 'H' && lifelines[i] == 1) { + hintForHardQuestions(randNum); + printf("Enter your answer (A, B, C, or D): "); + scanf(" %c", &user_answers[randNum]); + user_answers[randNum] = toupper(user_answers[randNum]); + lifelines[i] = 0; + }else { user_answers[randNum] = response; } // check each answer diff --git a/src/main/quizproject.h b/src/main/quizproject.h index 482f4a9..fb61913 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -17,7 +17,7 @@ void printOutOption(char [][100], char [][100],char [], int, int, int[] ); void looping(char [][100], char [][100], char [], int []); void displayThankYouMessage(void); int* randomNumber(); -char answers[NUM_QUESTIONS] = {'B', 'A'}; +void hintForHardQuestions(int); #define NUM_QUESTIONS 5