Python 存储卡/磁贴cgame
目前正在用python开发一款存储卡游戏。那里有一张写着单词的卡片 两张卡片包含相同的单词,您尝试收集具有相同单词的成对卡片 例如,如果板上有10张卡片,则有5个单词。将两张卡片连成一行,用同一个单词翻动,就可以得到一对。如果你搞错了,两张牌都会翻转过来。这个游戏让我想起了一点游戏,但我的版本使用了文字 我目前的代码乱七八糟,但我只是个初学者。我现在陷入困境,不知道如何继续。如果有人能帮我一点忙,我将不胜感激Python 存储卡/磁贴cgame,python,Python,目前正在用python开发一款存储卡游戏。那里有一张写着单词的卡片 两张卡片包含相同的单词,您尝试收集具有相同单词的成对卡片 例如,如果板上有10张卡片,则有5个单词。将两张卡片连成一行,用同一个单词翻动,就可以得到一对。如果你搞错了,两张牌都会翻转过来。这个游戏让我想起了一点游戏,但我的版本使用了文字 我目前的代码乱七八糟,但我只是个初学者。我现在陷入困境,不知道如何继续。如果有人能帮我一点忙,我将不胜感激 class Playingboard: def __init__(self,
class Playingboard:
def __init__(self, points):
self.points = points
def randomCard(self):
for row in range(1, 5);:
for column in range(1, 5):
print (i*j, end " ")
print()
class Cards:
def __init__(self, ShowCard = False, word):
#
self.ShowCard = ShowCard
self.word = word
def ShowCard(self):
#Shows the word
def __lt__ (self):
#Compares the cards to see if it's the same word
wordlist =[car, computer, house, speaker, piano, drums]
cardlist = []
amount_word = 6
for i in amount_word:
card = Card(wordlist[i])
cardlist.append(card)
cardlist.append(card)
首先要做的是运行代码。当Python抛出错误时,请修复程序的该部分,使其不会导致错误。然后,重复这个过程,直到整个过程运行时没有任何错误 在您发布代码时,代码中有许多错误。下面是您的代码副本,它将在没有任何错误的情况下运行。我建议您将其与您的版本进行比较,这样您就可以看到您在哪里犯了错误
class Playingboard:
def __init__(self, points):
self.points = points
def randomCard(self):
for row in range(1, 5):
for column in range(1, 5):
print (i*j, end = " ")
print()
class Cards:
def __init__(self, word, ShowCard = False):
#
self.ShowCard = ShowCard
self.word = word
def ShowCard(self):
pass
#Shows the word
def __lt__ (self):
pass
#Compares the cards to see if it's the same word
wordlist =['car', 'computer', 'house', 'speaker', 'piano', 'drums']
cardlist = []
for word in wordlist :
card = Cards(word)
cardlist.append(card)
cardlist.append(card)
你被困在哪里?你想做什么?我试着弄清楚ShowCard,但是。不知道如何定义它。