Hey all,
I have a class with various methods and I want to pass the output of one method into the next method. For example:
class RockPaperScissors:
'''Rock paper scissors game, best of 3'''
tries = 3
def __init__(self, name):
'Reads in users call'
self.name = name
print 'You picked %s' % self.name #%d if define a class variable
RockPaperScissors.tries -= 1
def random(self):
'Generates a random number'
number = randint(1, 3000)
print number
'Test if even or odd'
if number <= 10:
output = 'paper'
elif number < 20:
output = 'scissors'
else:
output = 'rock'
def decision(self):
'Decides if win or loss'
print ???????
At the end of the code, I'd like to print the output from def random; however, I'm not sure how to tell the code to recognize that output was used in the above method/instance.
I see there is a lot of information on how to pass variables between classes, but not on instances. Also, if anyone could recommend a better random number generator than the one from random array input, that would be really helpful. Also, am I confusing the terminology of instance and method here?
Thanks.