Write a program in which you will be quizzed on your knowledge of Indian cuisine and its dishes. The data for this exercise can be downloaded here.
After loading the data from the provided indian_food.csv
file, each round the computer will select a random dish and the user will be asked what course this dish (normally) belongs to. The only answer possibilities are:
For each correctly answered question, the user gets a point and moves on to the next question. As soon as the user gives a wrong answer, the program will terminate. There is no maximum to the number of questions a user can get. Also, we will not worry about getting the same question multiple times.
To build this, you should implement a class FoodQuiz
that is able to generate questions and keep track of the game. At the very least, implement the following methods:
getQuestionText()
which returns the description of the current question.getScore()
which will return the current scoregetAnswer()
to be able to print out the answer (in case the game is over)getAnswerOptions()
which will return the previously mentioned answer optionscheckAnswer(String answerText)
which checks whether or not the answer is correctnextQuestion()
that can be used to have the quiz generate a new questionIt is highly recommended that you think about other classes you might need besides the FoodQuiz
.
Feel free to make improvements you want!
Hints:
FoodQuiz
. (E.g. Why do you think we split up getAnswer()
and the checkAnswer(...)
method?)********** Question 1: **********
Dish name: Navrattan korma
Ingredients: Green beans, potatoes, khus khus, low fat, garam masala powder
What type of dish is described above?
1. main course
2. dessert
3. starter
4. snack
Please enter the number of your answer: 1
Correct! SCORE: 1.
********** Question 2: **********
Dish name: Shrikhand
Ingredients: Curd, sugar, saffron, cardamom
What type of dish is described above?
1. main course
2. dessert
3. starter
4. snack
Please enter a value: 2
Correct! SCORE: 2.
********** Question 3: **********
Dish name: Sambar
Ingredients: Pigeon peas, eggplant, drumsticks, sambar powder, tamarind
What type of dish is described above?
1. main course
2. dessert
3. starter
4. snack
Please enter a value: 3
That's WRONG! It was a main course. GAME OVER.
Process finished with exit code 0