我正在udemy.com上学习python几周,而对于我的OOP课程,导师要求我们创建一个二十一点游戏。我的第一个任务是为甲板创建一个类。我做了这个:
class Deck(object):
totalCards = 0
deck = [
["A", totalCards],
["2", totalCards],
["3", totalCards],
["4", totalCards],
["5", totalCards],
["6", totalCards],
["7", totalCards],
["8", totalCards],
["9", totalCards],
["10", totalCards],
["J", totalCards],
["Q", totalCards],
["K", totalCards],
]
def __init__(self, numberOfDecks):
self.numberOfDecks = numberOfDecks
Deck.totalCards = numberOfDecks * 4
def printDeck():
for i in Deck.deck:
print i
newDeck = Deck(6)
newDeck.printDeck()
事情是......当我尝试打印套牌时,我得到并且错误告诉我printDeck方法没有参数,我正在传递一个。我不知道为什么..有谁可以帮助我?