diff --git a/AvaFinalProject.txt b/AvaFinalProject.txt new file mode 100644 index 0000000..e506793 --- /dev/null +++ b/AvaFinalProject.txt @@ -0,0 +1,16 @@ +Ava N. +July 9, 2016 + +Final Project Proposal: + +For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well. + +The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well. + +An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant. + +I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes. + +Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before. + +This is my Final Project Proposal and I am excited to start working on it (once it is approved)! diff --git a/FinalProject/answer.txt b/FinalProject/answer.txt new file mode 100644 index 0000000..e3d6b2f --- /dev/null +++ b/FinalProject/answer.txt @@ -0,0 +1,30 @@ +Army +Switzerland +Hyena +New York City +Mudd +Winter +700 +February +Bonjour +Whale +1492 +Abacus +Orange +P +Hydrogen +24 +Nile River +Mount Everest +Elvis Presley +Damascus +Sicily +Venezuela +Retriever +1984 +Theodore Roosevelt +6 +1509 +Queue +Ada Lovelace +Yes diff --git a/FinalProject/extra.c b/FinalProject/extra.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/FinalProject/extra.c @@ -0,0 +1 @@ + diff --git a/FinalProject/questions.txt b/FinalProject/questions.txt new file mode 100644 index 0000000..c588520 --- /dev/null +++ b/FinalProject/questions.txt @@ -0,0 +1,30 @@ +1. What is a group of frogs known as? +2. What country has the highest environmental performance index? +3. Which animal laughs like human being? +4. In which city is manhattan located? +5. In which building is the Columbia HSP for Intro to Programming in C? +6. During what season do animals hybernate? +7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)? +8. In what month is Valentine's Day? +9. How do you say 'Hello/Good morning' in french? +10. Which underwater creature is bigger: Dolphin or Whale? +11. In what year did Christopher Columbus sail the ocean blue? +12. What device was used to solve math problems before the invention of electricity? +13. What color comes after red in the rainbow? +14. What is the 16th letter in the alphabet? +15. What is the first element in the periodic table (not in scientific notation)? +16. How many students are in the Introduction to Programming in C class? +17. What is the longest river in the world? (include 'River' at the end of answer) +18. What is the highest mountain in the world? +19. Who is known for being the King of Rock 'n Roll? +20. What is the world's oldest city? +21. What is the largest island in the Mediterranean sea? +22. In what country is the highest waterfall in the world? +23. What is the most popoular breed of dog? +24. In which year was the first computer sold with a mouse? +25. Who was the youngest President in the United States? +26. How many legs do butterflies have? +27. In which year did Henry VIII become King of England? +28. What is a linear data structure in which elements are added on one end and removed from the other? +29. Which female mathematician developed the first algorithm for the Analytical Machine? +30. Did you enjoy playing? (Yes/No) diff --git a/FinalProject/quiz_game b/FinalProject/quiz_game new file mode 100755 index 0000000..a480b26 Binary files /dev/null and b/FinalProject/quiz_game differ diff --git a/FinalProject/quiz_game.c b/FinalProject/quiz_game.c new file mode 100644 index 0000000..fea92ad --- /dev/null +++ b/FinalProject/quiz_game.c @@ -0,0 +1,170 @@ +//Ava N.'s + +//REAL VERSION -- Ava's Quiz Show +//Columbia HSP FInal Project +//Intro to Programming in C +//Due: July 15, 2016 + +#include +#include +#include +#include + + +void help(){ //gives instructions of the game + system("clear"); + printf("\n\n Instructions:"); + printf("\n ------------------------------------------------------"); + printf("\n ................... Ava's Quiz Show ...................."); + printf("\n >> You have to be able to answer 30 questions correctly."); + printf("\n >> All of the questions require fill-in answers."); + printf("\n >> This game is case-sensitive, so all answers have to"); + printf("\n have the first letter of each word uppercase."); + printf("\n >> If the question asks for a number, answer with a number."); + printf("\n >> The maximum number of points a you can get is 11."); + + printf("\n >> You will not be penalized for incorrect answers."); + + printf("\n\n\t**************Good Luck*******************\n\n"); + printf("\n\n\t Press 'enter' to continue to the main menu\n"); +} + + + +//start of the game show +int main(void){ + + system("clear"); + char filename[] = "questions.txt"; //opens the questions + char answersFile[]= "answer.txt"; //opens the answers + char ques_arr[1000]; //questions array + char ans_arr[100]; //answers array + char guess[100]; //the contestant's guess + FILE *questions = fopen(filename, "r"); + FILE *answers = fopen(answersFile, "r"); + int i; //variable for loop that checks contestants answers + int e; //variable for going through the questions.txt file + const int num_ques=29; //includes number of questions + char choice; //main menu variable + int countr = 0; //score + + mainhome: + system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program + //printf("\t\t\tC PROGRAM QUIZ GAME\n"); + printf("\n\t\t________________________________________"); + + printf("\n\t\t\t * WELCOME *"); + printf("\n\t\t\t * to *"); + printf("\n\t\t\t * AVA'S GAME SHOW *"); + printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____"); + printf("\n\t\t________________________________________"); + printf("\n\t\t\t BECOME THE CHAMPION!!! ") ; + printf("\n\t\t________________________________________"); + printf("\n\t\t________________________________________"); + printf("\n\t\t > Press S to start the game"); + printf("\n\t\t > press H for help "); + printf("\n\t\t > press Q to quit "); + printf("\n\t\t________________________________________\n\n"); + + + printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n"); +//MAIN MENU SELECTION OPTIONS + choice=toupper(getchar()); + printf("you entered %c\n",choice); + + if (toupper(getchar())=='S') + goto home; + else if (choice=='H'){ + printf("you typed in H"); + help(); + getchar(); + goto mainhome; + } + else if (choice=='Q'){ + printf("you typed in Q"); + exit(1); + + } + + + home: +//HAVING QUESTIONS PRINT ONE AT A TIME + for (e=0; e < num_ques; e++) //loop to go through each question in text file + { + //printf("\nQuestion:"); + printf("\n***Type in your answer to the following question:\n\n"); + + if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL) + { + printf("%s\n", ques_arr); + } + +//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c + + if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL) + { + fprintf(stderr,"Error while reading file\n"); + return -1; + } + + + + for (i=0; i < 1; i++) + { + // printf("%d\n",i); + //fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr); + //printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess); + fgets(guess, sizeof(guess), stdin); + + //fprintf(stderr,"you answered %s\n",guess); + + if (strcmp(ans_arr, guess) == 0) + { + printf("Your guess was correct\n\n"); + countr++; + } + else if (guess!=ans_arr) + { + printf("Your guess was incorrect.\n"); + printf("The answer was: %s\n\n\n\n", ans_arr); + } + else + { + printf("You ran out of questions."); + } + } + } + + + fclose(questions); + fclose(answers); + +//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT + score: + system("clear"); + //score=countr; + //printf("* DIAGNOSTIC -- countr is %d\n",countr); + //printf("* DIAGNOSTIC -- score is %d\n",score); + if(countr>0 && countr<=29){ + printf("\n\n\t\t************* CONGRATULATIONS **************"); + printf("\n\t\t\t You won %d points! \n", countr); + } + + else if(countr==30){ //highest score possible + printf("\n\n\n \t\t*********** Nice Job!! ***********"); + printf("\n\t\t\t\t You are the champion!!!!!!!!!"); + printf("\n\t\t\t You won %d points! \n",countr); + printf("\t\t Thank You!!"); + } + else{ + printf("\n\n\t******** You did not win any points ********"); + printf("\n\t\t Thanks for playing!. \n"); + printf("\n\t\t Better luck next time! \n"); + } + + + + return 0; + + + } diff --git a/FinalProject/readme.txt b/FinalProject/readme.txt new file mode 100644 index 0000000..3dc2c55 --- /dev/null +++ b/FinalProject/readme.txt @@ -0,0 +1,30 @@ +Ava N. +July 15, 2016 +Ava's Quiz Game + +This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game. + + +In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'! + +All of the answers to the questions, if you want to beat the game, are in answer.txt . + + +I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/ + + + +Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file. + + +I hope you enjoy Ava's Quiz Show! + + + +compile statement: + gcc quiz_game.c -o quiz_game + ./quiz_game + + + + diff --git a/FinalProject/sam b/FinalProject/sam new file mode 100755 index 0000000..96a30e8 Binary files /dev/null and b/FinalProject/sam differ diff --git a/FinalProject/sample_doc.c b/FinalProject/sample_doc.c new file mode 100644 index 0000000..9187e89 --- /dev/null +++ b/FinalProject/sample_doc.c @@ -0,0 +1,59 @@ +//This is for checking the code of the question-answer section in quiz_game code + +#include +#include + +int main (void){ + char filename[] = "questions.txt"; //opens the questions + char answersFile[]= "answer.txt"; //opens the answers + char ques_arr[1000]; //questions array + char ans_arr[100]; //answers array + char guess[25]; //the contestant's guess + FILE *questions = fopen(filename, "r"); + FILE *answers = fopen(answersFile, "r"); + int i; + int e; + const int num_ques=5; + for (e=0; e < num_ques; e++){ + + printf("Type in your answer to the following question:\n"); + + if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file + printf("%s\n", ques_arr); + } + + //source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c + if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){ + fprintf(stderr,"Error while reading file\n"); + return -1; + } + + for (i=0; i < 1; i++){ //Loop for questions asking + //printf("%d\n",i); + //fprintf(stderr,"the answer: %s\n", ans_arr); + //printf("Please guess the word: \n"); + fgets(guess, sizeof(guess), stdin); + + fprintf(stderr,"you answered %s\n",guess); + if (strcmp(ans_arr, guess) == 0){ + printf("Your guess was correct\n\n"); + //continue; + } + else if (guess!=ans_arr){ + printf("Your guess was incorrect.\n\n\n"); + //continue; + } + else { + printf("You ran out of questions"); + //break; + } + } + } + + + fclose(questions); + fclose(answers); + return 0; +} + + diff --git a/FinalProject/temp b/FinalProject/temp new file mode 100755 index 0000000..99393eb Binary files /dev/null and b/FinalProject/temp differ diff --git a/FinalProject/temp.c b/FinalProject/temp.c new file mode 100644 index 0000000..dab7b6f --- /dev/null +++ b/FinalProject/temp.c @@ -0,0 +1,190 @@ +//Test Version + +//Quiz Show game in C for Final Project at Columbia HSP 2016 + +//Idea of how to set up the code: + +#include +#include +#include +#include + + +void help(){ //gives instructions of the game + system("clear"); + printf("\n\n Instructions:"); + printf("\n ------------------------------------------------------"); + printf("\n ................... Ava's Quiz Show ...................."); + printf("\n >> You have to be able to answer 11 questions."); + printf("\n >> All of the questions require fill-in answers."); + printf("\n >> This game is NOT case sensative, so all answers have to"); + printf("\n have the beginning of words be uppercase."); + printf("\n >> If the question asks for a number, answer with a number"); + printf("\n >> The maximum number of points a you can get is 11."); + + printf("\n >> You will not be penalized for getting answers incorrect"); + + printf("\n\n\t**************Good Luck*******************\n\n"); + printf("\n\n\t Press 'enter' to continue to the main menu\n"); +} + + + +//start of the game show +int main(void){ + + system("clear"); + char filename[] = "questions.txt"; //opens the questions + char answersFile[]= "answer.txt"; //opens the answers + char ques_arr[1000]; //questions array + char ans_arr[100]; //answers array + char guess[25]; //the contestant's guess + FILE *questions = fopen(filename, "r"); + FILE *answers = fopen(answersFile, "r"); + int i; + int e; + const int num_ques=10; + int score; + char choice; + int countr =0; + char userinput[20]; + char playername[20]; + char loop='y'; + //while (loop == 'y'); + mainhome: + system("clear"); //source: stackoverflow.com + printf("\t\t\tC PROGRAM QUIZ GAME\n"); + printf("\n\t\t________________________________________"); + + printf("\n\t\t\t * WELCOME *"); + printf("\n\t\t\t * to *"); + printf("\n\t\t\t * AVA'S GAME SHOW *"); + printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____"); + printf("\n\t\t________________________________________"); + printf("\n\t\t\t BECOME THE CHAMPION!!! ") ; + printf("\n\t\t________________________________________"); + printf("\n\t\t________________________________________"); + printf("\n\t\t > Press S to start the game"); + printf("\n\t\t > press H for help "); + printf("\n\t\t > press Q to quit "); + printf("\n\t\t________________________________________\n\n"); + + + + //printf("\n\n\n Press Y to start the game!\n"); + choice=toupper(getchar()); + printf("you entered %c\n",choice); + + if (toupper(getchar())=='S') + goto home; + else if (choice=='H'){ + printf("you typed in H"); + help(); + getchar(); + goto mainhome; + } + else if (choice=='Q'){ + printf("you typed in Q"); + exit(1); + + } + home: + +//HAVING QUESTIONS PRINT ONE AT A TIME + + + for (e=0; e < num_ques; e++) //loop to go through each question in the text file + { + //printf("\nQuestion:"); + printf("\n***Type in your answer to the following question:\n\n"); + + if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL) + { + printf("%s\n", ques_arr); + } + +//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c + + if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL) + { + fprintf(stderr,"Error while reading file\n"); + return -1; + } + + + + for (i=0; i < 1; i++) + { + // printf("%d\n",i); + //fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr); + //printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess); + fgets(guess, sizeof(guess), stdin); + + //fprintf(stderr,"you answered %s\n",guess); + + if (strcmp(ans_arr, guess) == 0) + { + printf("Your guess was correct\n\n"); + countr++; + //continue; + } + else if (guess!=ans_arr) + { + printf("Your guess was incorrect.\n\n\n"); + //continue; + } + else + { + printf("You ran out of questions."); + //break; + } + } + } + + + fclose(questions); + fclose(answers); + //return 0; + + + score: + system("clear"); + score=countr; + //printf("* DIAGNOSTIC -- countr is %d\n",countr); + //printf("* DIAGNOSTIC -- score is %d\n",score); + if(score>0 && score<=10){ + printf("\n\n\t\t************* CONGRATULATIONS **************"); + printf("\n\t You won %d points! \n",score);goto go;} + + else if(score==11){ //highest score possible + printf("\n\n\n \t\t*********** Nice Job!! ***********"); + printf("\n\t\t\t\t You are the champion!!!!!!!!!"); + printf("\n\t\t\t You won %d points! \n",score); + printf("\t\t Thank You!!"); + } + else{ + printf("\n\n\t******** You did not win any points ********"); + printf("\n\t\t Thanks for playing!. \n"); + printf("\n\t\t Better luck next time! \n");goto + go; + } + + go: + //puts("\n\n Press Y if you want to play again"); + //puts("Play again next time!\n"); + //printf("Do you want to play again? (y/n)"); //source: my Assignment 4 hangman.c + //scanf("%c", &loop); + //if (loop != 'y') + //loop; 'n'; + + return 0; + if (toupper(getchar())=='Y') + goto mainhome; + /*else{ + edit_score(score,playername); + goto mainhome; + }*/ + } +//} +//}//this was put here after the cases were commented out. +//}