This is a command-line quiz game written in Go. The game reads questions from a CSV file, asks each question to the player, and tracks their score based on correct answers. The game includes a timer that limits the duration of the quiz, and an option to shuffle the questions for a fresh experience each time.
- Clone or download this repository.
- Build the Go application:
go build -o quiz
- Run the quiz game from the command line:
./quiz
By default, the quiz will read questions from problems.csv, and you'll have 30 seconds to answer as many questions as possible.
- CSV-based Questions: The game reads questions and answers from a CSV file. Each row in the CSV file should contain a question in the first column and the answer in the second column, e.g.:
What is the capital of France?,Paris
5+7,12
- Timed Quiz: The quiz is time-limited. You can set a custom time limit using the -timer flag.
- Shuffle Option: Randomly shuffle the order of questions with the -shuffle flag.
The game has a few command-line flags that allow you to customize the experience:
-filename: Specify a custom CSV file with questions. If not provided, it defaults to problems.csv.
./quiz -filename=science.csv
-timer: Set a custom time limit (in seconds) for the quiz. The default is 30 seconds.
./quiz -timer=60
-shuffle: Shuffle the order of questions. This flag does not require any additional input; it just needs to be added to the command.
./quiz -shuffle
Here are a few ways to run the quiz with different options:
./quiz
./quiz -filename=science.csv
./quiz -timer=45
./quiz -shuffle
./quiz -filename=history.csv -timer=60 -shuffle=true
At the end of the quiz, the game displays your score by showing the number of correct answers out of the total questions attempted.
Example Output:
Press Enter to start the quiz...
Question 1: What is the capital of France? = Paris
Correct!
Question 2: 5 + 7 = 13
Incorrect. The correct answer is 12.
...
Time's up!
You scored 5 out of 10.
Enjoy testing your knowledge with this Go quiz game!