Struggling with program
jeanmichel at sequans.com
Mon Feb 18 11:25:06 CET 2013
----- Original Message -----
> I'm trying to do this assignment and it not working, I don't
> understand why...
> This is what I have to do:
> Write the definition of a class Player containing:
> An instance variable name of type String , initialized to the empty
> An instance variable score of type int , initialized to zero.
> A method called set_name that has one parameter, whose value it
> assigns to the instance variable name .
> A method called set_score that has one parameter, whose value it
> assigns to the instance variable score .
> A method called get_name that has no parameters and that returns the
> value of the instance variable name .
> A method called get_score that has no parameters and that returns
> the value of the instance variable score .
> No constructor need be defined.
> Here is my code:
> class Player:
> name = ''
> def __init__(self,score = 0)
> def set_name (self):
> def set_score (self):
> def get_name
> return name
> def get_score
> return score
> can someone please help me?
# here are class attributes
foo = 'I am a class attribute'
# now the methods
# instance attributes
self.name = ''
self.score = 0
def set_name(self, name):
self.name = name
I hope you'll be able to figure how to write the score related methods.
-- IMPORTANT NOTICE:
The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
More information about the Python-list