README ¶
Golang Quiz Game Exercise
My Implementation of the Go Quiz on Jon Calhoun's Gophercises Course. The requirements for this exercise are posted here.
You can review the documentation generated by Go for the code here.
Command Line Options
The quiz game executable displays help if you pass the help parameter.
$ ./quiz help
------------------------
quiz - play a quiz game
** syntax -var=Value **
-filepath string
A CSV file containing quiz questions (default "problems.csv")
-h string
Print this help text
-help string
Print this help text
-shuffle
When set to True, the quiz questions are shuffled. (default "false")
-timelimit duration
Time limit for the test (default 30s)
-totalquestions int
Number of questions in the test.
If no count is provided then all questions in the file will be used.
------------------------
Sample Output
The following is a sample of the output with no options provided.
$ ./quiz
Welcome to the Quiz Game
Please enter your name: Rob
You have 30s to finish the test. There are 12 questions in the test.
Press ENTER to start the test
1. 5+5 = 10
2. 1+1 = 2
3. 8+3 = 10
4. 1+2 = 4
5. 8+6 = 14
6. 3+1 = 4
7. 1+4 = 5
8. 5+1 = 6
9. 2+3 = 5
10. 3+3 = 6
11. 2+4 = 4
12. 5+2 = 7
You answered all 12 questions in 21.01 seconds.
There were 8.99 seconds remaining on the clock.
You got 9 questions right and 3 questions wrong.
Your score is 75.00% Rob!
+----+----------+--------+-------------+---------+
| # | QUESTION | ANSWER | USER ANSWER | CORRECT |
+----+----------+--------+-------------+---------+
| 1 | 5+5 | 10 | 10 | true |
| 2 | 1+1 | 2 | 2 | true |
| 3 | 8+3 | 11 | 10 | false |
| 4 | 1+2 | 3 | 4 | false |
| 5 | 8+6 | 14 | 14 | true |
| 6 | 3+1 | 4 | 4 | true |
| 7 | 1+4 | 5 | 5 | true |
| 8 | 5+1 | 6 | 6 | true |
| 9 | 2+3 | 5 | 5 | true |
| 10 | 3+3 | 6 | 6 | true |
| 11 | 2+4 | 6 | 4 | false |
| 12 | 5+2 | 7 | 7 | true |
+----+----------+--------+-------------+---------+
A Timed Quiz
When the timer runs out, the execution flow is immediately interrupted and the results are returned.
$ ./quiz -timelimit=10s -totalquestions=6 -shuffle=true
Welcome to the Quiz Game
Please enter your name: Rob
You have 10s to finish the test. There are 6 questions in the test.
Press ENTER to start the test
1. 8+3 = 11
2. 8+6 = 10
3. 1+1 = 2
4. 1+2 =
Time's Up Rob!
You answered 3 questions out of a total of 6 questions in 10.00 seconds.
You got 2 questions right and 1 questions wrong.
Your score is 33.33% Rob!
+---+----------+--------+-------------+---------+
| # | QUESTION | ANSWER | USER ANSWER | CORRECT |
+---+----------+--------+-------------+---------+
| 1 | 8+3 | 11 | 11 | true |
| 2 | 8+6 | 14 | 10 | false |
| 3 | 1+1 | 2 | 2 | true |
| 4 | 1+2 | 3 | | false |
| 5 | 3+1 | 4 | | false |
| 6 | 5+5 | 10 | | false |
+---+----------+--------+-------------+---------+
What I Learned
- Creating struct types with methods
- Reading csv files
- Parsing commandline arguments
- Working with constrol structures including if statements and for loops
- Working with pointers and references
- Pulling in and using a package from another Github repository
- Formatting and printing text to std out
- Parsing input from the commandline
Documentation ¶
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.