What i need to do is create a class called MathGame that has the following methods:
-
One method randomly creates a mathematical expression consisting of 2 numbers and a randomly generated mathematical operator (example 3 + 4=)
-
One method prints the equation to the screen
-
One method gets the correct answer
-
One method gets the user’s answer and tells them if they are correct or not
The problem I am having is I think I have 1 and 2 but not sure how to do 3 and 4 here is my code so far:
import random
class MathGame:
maxGuesses = 15
correctNumber = 0
numAttempts = 0
def _init_(self, maximumGuesses):
self.maxGuesses = maixmumGuesses
def generateNumber(self, min, max):
self.correctNumber = random.randint(min,max)
def guessCorrect(self, value):
resturnAnswer = False
if(self.correctNumber == value):
returnAnswer = True
return returnAnswer
def guessWrong(self, value):
returnAnswer = False
if(self.correctNumber != value):
returnAnswer = True
return returnAnswer
def userNumber(value):
num1 = input(int())
num2 = input(int())
def mathOperators():
add = ('+')
sub = ('-')
mult = ('*')
div = ('/')
def equation():
equ = str('num1', 'random.mathOperators', 'num2', '=')
print('equ')