Question: 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

Need help coding these classes in python For this lab, you willbe constructing a simple quiz game using classes. You will need tocomplete the following: Part 1 - Question Class Create a class that

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!