存储卡/磁贴cgame



目前正在python中开发一款存储卡游戏。那里有一块写着字的卡片板。

两张卡片包含相同的单词,然后你尝试收集具有相同单词的成对卡片。

例如,如果棋盘上有10张牌,则有5个单词。你可以把同一个单词的两张卡片连在一起翻转,得到两张卡片。如果你弄错了,两张牌都会反过来。这个游戏让人想起了这个游戏,但我的版本使用了文字。

我当前的代码一团糟,但我只是个初学者。我目前陷入困境,不知道如何继续。如果有人能帮我一点忙,我将不胜感激。

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)

最新更新