我需要一些关于从哪里开始这项作业的指导。我们必须编写一个程序来简单地跟踪每张卡片从牌组发送到玩家、计算机的位置,或者它是否仍在牌组中。
我的教授给了我们必须使用且不允许更改的入门代码
""" cardGame.py
basic card game framework
keeps track of card locations for as many hands as needed
"""
from random import *
NUMCARDS = 52
DECK = 0
PLAYER = 1
COMP = 2
cardLoc = [0] * NUMCARDS
suitName = ("hearts", "diamonds", "spades", "clubs")
rankName = ("Ace", "Two", "Three", "Four", "Five", "Six", "Seven",
"Eight", "Nine", "Ten", "Jack", "Queen", "King")
playerName = ("deck", "player", "computer")
def main():
clearDeck()
for i in range(5):
assignCard(PLAYER)
assignCard(COMP)
showDeck()
showHand(PLAYER)
showHand(COMP)
关于我想要的每个函数,showDeck()、showHand(PLAYER)、showHand(COMP) 和 clearDeck() 函数的一个小想法,我有一些想法。我只需要一些指导来确定这是否需要创建一个类,或者只是使用数组(我读过的python中的列表)来跟踪每张卡。对于如何创建一个可以跟踪所有卡片的套牌,我也将不胜感激。谢谢你的时间!