Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39060

Struggling with program

Newsgroups comp.lang.python
Date 2013-02-17 18:29 -0800
Message-ID <5d90a61d-f122-4dd4-8d79-c9909662b2bc@googlegroups.com> (permalink)
Subject Struggling with program
From maiden129 <sengokubasarafever@gmail.com>

Show all headers | View raw


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 String.
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):
		self.name

	def set_score (self):
		self.score

	def get_name
		return name
	
	def  get_score
		return score

can someone please help me?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Struggling  with program maiden129 <sengokubasarafever@gmail.com> - 2013-02-17 18:29 -0800
  Re: Struggling  with program Dave Angel <davea@davea.name> - 2013-02-17 21:49 -0500
  Re: Struggling  with program Michael Torrie <torriem@gmail.com> - 2013-02-17 20:49 -0700
  Re: Struggling with program Chris Angelico <rosuav@gmail.com> - 2013-02-18 17:49 +1100

csiph-web