Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

: : # Write the WOFComputerPlayer class definition (part C) here class WOFComputerPlayer(WOFPlayer): SORTED_FREQUENCIES = 'ZQXJKVBPYGFWMUCLDRHSNIOATE' def __init__(self, name, difficulty): WOFPlayer.__init__(self, name) self.difficulty = difficulty

: : # Write the WOFComputerPlayer class definition (part C) here class WOFComputerPlayer(WOFPlayer): SORTED_FREQUENCIES = 'ZQXJKVBPYGFWMUCLDRHSNIOATE' def __init__(self, name, difficulty): WOFPlayer.__init__(self, name) self.difficulty = difficulty def smartCoinFlip(self): randnum = random.randint(1, 10) if self.difficulty > randnum: return True else: return False def getPossibleLetters(self, guessed): output = [] try: for c in LETTERS: if c.lower() not in guessed and c not in guessed and c in VOWELS and self.prizeMoney >= 250: output.append(c) elif c.lower() not in guessed and c not in guessed and c not in VOWELS: output.append(c) except Exception as e: print("Error", e) return output def getMove(self, category, obscuredPhrase, guessed): if guessed == []: return 'pass' elif self.smartCoinFlip() == True: return SORTED_FREQUENCIES[-1] elif self.smartCoinFlip() == False: return random.choice(self.getPossibleLetters(guessed)) 

=================

I have to define a class variable 'SORTED_FREQUENCIES'.

But when I define a class variable in the class 'WOFComputerPlayer', I can't call the variable within a method.

Why I can't call the class variable which is 'SORTED_FREQUENCIES' within a method(getMove)?

Is there a way to define a class variable and also use it within a method ?

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

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

=+country competitive advantages? Why? Support your point of view.

Answered: 1 week ago