Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help coding these classes in python For this lab, you will be constructing a simple quiz game using classes. You will need to complete

Need help coding these classes in python

image text in transcribedimage text in transcribedimage text in transcribed

For this lab, you will be constructing a simple quiz game using classes. You will need to complete the following: Part 1 - Question Class Create a class that has the following attributes: 1. question 2. answer For example, your question can be something like the following - question: Is 7 a prime number? - answer:yes To keep it simple for now, we can create open-ended answers, but a good version of this game might utilize multiple choice questions! - question: Which of these is a prime number? - A. 4 - B. 7 - C. 9 - D. 10 - answer: B Constructor: Your Question class should also contain a constructor (init function) to set the Question and Correct Answer attributes (not usin console input) Part 2 - Quiz Class (Attributes) Define a class Quiz that has the following attributes: 1. quizQuestions - A list of quiz Question objects 2. currentScore - should keep track of the player's score, and will start at zero with each game 3. topscores - this should be a dictionary of player names and their scores who have played this quiz 4. currentPlayerName - this will hold the name of the player currently playing your game 3. displayScore() - inputs: self - this method should display the user's score (will be run once the quiz is done) - this should also add the user's top score entry to topscores 4. addQuestion() - inputs: self, question object - this method should take in a question object and add it to the quiz question list 5. startGame() - inputs: self - this method should ask for the player's name (console input) and store it in currentPlayerName - the score will also be reset to zero here - Next, the method should play each question using playQuestion() for each question in the quizQuestions attribute - Once the questions are complete, the game should use displayScore() to show the user's final score and save it to the topscores attribute

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions