这是我的课:
class Player(object):
def __init__(self, playernum):
self.playernum = playernum
def play_turn(self, board):
"""This method is passed an instance of ConnectFour.
It should examine the board (using methods on the ConnectFour class...
assume you have it) and eventually call board.play_turn and return"""
pass
到目前为止,我明白如果我这样做:
class Human(Player):
它将使 Human() 成为 Player 的派生类。
我想做的是在这个类中有一个构造函数 playernum。然后获取覆盖的 play_turn 并打印一个玩家编号(即 playernum)......我只想知道这将如何实现......我重复一遍吗
def play_turn(self,board):
在 Human 类中,还是我简单地说
class Human(Player):
play_turn
和里面
play_turn(self,board):
"put"
print playernum
我对类的派生及其背后的逻辑有点陌生。任何输入将不胜感激。谢谢。