quiz

command module
v0.0.0-...-160e930 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2020 License: MIT Imports: 9 Imported by: 0

README

Exercise #1: Quiz Game

Exercise details

This exercise is broken into two parts to help simplify the process of explaining it as well as to make it easier to solve.

Part 1

Create a program that will read in a quiz provided via a CSV file (more details comming) and will the give the quiz to a user keeping track of how many question they get right and how many they get incorrect. Regardless of whether the answer is correct or wrong the next question should be asked immediately afterwards.

The CSV file should default to problems.csv (example shown below), but the user should be able to customize the filename via a flag.

The CSV file will be in a format like bellow, where the first columns is a question and the second column in the same row is the answer to that question.

5+5,10
7+3,10
1+1,2
8+3,11
1+2,3
8+6,14
3+1,4
1+4,5
5+1,6
2+3,5
3+3,6
2+4,6
5+7,6

You can assume that quizzes will be relatively short (< 100 questions) and will have single word/number answers.

At the end of the quiz the program should output the total number of questions correct and how manny questions there were in total. Questions give invalid answers are considered incorrect.

NOTE: CSV files may have questions with commas in them. Eg: what 2+2, sir?,4 is valid row in a CSV. Use the CSV package in Go and don't try to write another wheel.

Part 2

Adapt you program from part 1 to add a timer. The default time limit should 30 seconds, but should also be customizable via a flag.

Your quiz should stop as soon as the time limit has exceeded. That is, you shouldn't wait for the user to answer one final questions but should ideally stop the quiz entirely even if you are currently waiting on another from the end user.

Users should be asked to press enter (or some other key) before the timer starts, and then the questions should be printed out to the screen one at a time until the user provides an answer. Regardless of whether the answer is correct or wrong the next question should be asked.

At the end of the quiz the program should still output the total number of questions correct and how many questions there were in total. Questions give invalid answers or unanswered are considered incorrect.

Bonus

As a bonus exercises you can also...

  1. Add string trimming and cleanup to help ensure that correct answers with extra whitespace, capitalization, etc are not considered incorrect. Hint: Checkout strings package.
  2. Add an option (a new flag) to shuffle the quiz order each time it it run.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL