57Trivia App

Create a multiple-choice trivia application.

  • Read questions, answers, and distractors (wrong answers) from a file.

  • When a player starts a game

    • Choose questions at random.

    • Display the answer and distractors in a random order.

    • Track the number of correct answers.

    • End the game when the player selects a wrong answer.

Constraint

  • Write this file using a file database or local data file rather than a key-value store or a relational database.

Challenges

  • Add a difficulty field for the questions, and present increasingly difficult questions as the game progresses.

  • Expand the program by adding a mode that allows a parent or teacher to add, edit, or remove questions and answers.

Get Exercises for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.