Dick Moores wrote:
> At 03:49 AM 10/30/2007, Kent Johnson wrote:
>> From here to simple classes is not a big step:
>>
>> class player(object):
>> def __init__(self, name, moveCounter, remainingTime):
>> self.name = name
>> self.moveCounter = moveCounter
>> self.remainingTime = remainingTime
>>
>> whitePlayer = player('White', 1, timeLimit)
>> blackPlayer = player('Black', 1, timeLimit)
>>
>> Then playerName(player) becomes player.name and
>> remainingPlayerTime(player) becomes player.remainingTime.
>
> Well, Kent (and Bob Gailer), thanks for trying to help with classes,
> but I still don't get them. I've just got to spend time with using
> classes in much simpler scripts. You guys may think my chessTimer is
> a piece of cake, but it stretched me a lot even without classes.
You aren't going to find a simpler use of classes. Maybe a simpler
script to use classes, but not a simpler class.
All you need to do (I think) is add the class definition, change the two
lines that create whitePlayer and blackPlayer, then change each list
access, such as
currentPlayer[NAME]
to an attribute access like
currentPlayer.name
Once you do that I think you will have a working program, then you can
think about possibly moving some code into methods.
Kent
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor