Skip to content

Commit 823490b

Browse files
committed
modify README.md
1 parent c4e3b86 commit 823490b

File tree

4 files changed

+102
-45
lines changed

4 files changed

+102
-45
lines changed

.idx/dev.nix

Lines changed: 0 additions & 42 deletions
This file was deleted.

README.md

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,102 @@
1-
This is a simple hello, world demonstration web server.
1+
# Go Quiz Game
22

3-
It serves version information on /version and answers any other request like /name by saying "Hello, name!".
3+
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.
4+
5+
## How to Play
6+
- Clone or download this repository.
7+
- Build the Go application:
8+
9+
```bash
10+
go build -o quiz
11+
```
12+
- Run the quiz game from the command line:
13+
14+
```bash
15+
./quiz
16+
```
17+
18+
By default, the quiz will read questions from problems.csv, and you'll have 30 seconds to answer as many questions as possible.
19+
20+
## Features
21+
22+
1. 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.:
23+
24+
```csv
25+
What is the capital of France?,Paris
26+
5+7,12
27+
```
28+
29+
2. **Timed Quiz**: The quiz is time-limited. You can set a custom time limit using the -timer flag.
30+
3. **Shuffle Option**: Randomly shuffle the order of questions with the -shuffle flag.
31+
32+
## Flags
33+
The game has a few command-line flags that allow you to customize the experience:
34+
35+
**-filename**: Specify a custom CSV file with questions. If not provided, it defaults to problems.csv.
36+
37+
```bash
38+
./quiz -filename=science.csv
39+
```
40+
41+
**-timer**: Set a custom time limit (in seconds) for the quiz. The default is 30 seconds.
42+
43+
```bash
44+
./quiz -timer=60
45+
```
46+
47+
**-shuffle**: Shuffle the order of questions. This flag does not require any additional input; it just needs to be added to the command.
48+
49+
```bash
50+
./quiz -shuffle
51+
```
52+
53+
## Example Usage
54+
Here are a few ways to run the quiz with different options:
55+
56+
### Basic Quiz with Default Settings:
57+
58+
```bash
59+
./quiz
60+
```
61+
### Using a Custom CSV File:
62+
63+
```bash
64+
./quiz -filename=science.csv
65+
```
66+
### Setting a Custom Time Limit:
67+
68+
```bash
69+
./quiz -timer=45
70+
```
71+
### Shuffling the Questions:
72+
73+
```bash
74+
./quiz -shuffle
75+
```
76+
77+
78+
### Combining Flags:
79+
80+
```bash
81+
./quiz -filename=history.csv -timer=60 -shuffle=true
82+
```
83+
## Scoring
84+
At the end of the quiz, the game displays your score by showing the number of correct answers out of the total questions attempted.
85+
86+
Example Output:
87+
```plaintext
88+
Press Enter to start the quiz...
89+
90+
Question 1: What is the capital of France? = Paris
91+
Correct!
92+
93+
Question 2: 5 + 7 = 13
94+
Incorrect. The correct answer is 12.
95+
96+
...
97+
98+
Time's up!
99+
You scored 5 out of 10.
100+
```
101+
102+
Enjoy testing your knowledge with this Go quiz game!

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func startQuiz(quiz []Question, timeLimit int, shuffle bool) {
8484

8585
answerCh := make(chan string)
8686

87-
quizLoop:
87+
quizLoop:
8888
for i, question := range quiz {
8989
fmt.Printf("Question %d: %s = \n", i+1, question.question)
9090

mymodule

-1.86 MB
Binary file not shown.

0 commit comments

Comments
 (0)