I'm doing a play of a game of cards and I'm having a problem calling the methods of class Deck()
, I've tried to redo some parts of the code and sometimes as an undefined object, I re-do it again and still nothing, could someone help me if possible? Thank you in advance.
Follow the code:
import random
class Card:
def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
def getRankeado(self):
return self.rank
def getSuit(self):
return self.suit
class Deck:
ranks = {'2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'}
suits = {'ZAP', 'COPAS', 'OURO', 'ESPADA'}
def __init__(self):
self.deck = []
for suit in Deck.suits:
for rank in Deck.ranks:
self.deck.append(Card(rank, suit))
def dealCard(self):
return self.deck.pop()
def __repr__(self):
return self.__repr()
def lenDeck(self):
return self.len(Deck)
def shuffle(self):
random.shuffle(self.deck)
def imprime(self):
return print(self.Deck, self.Card)
#saidas
c = Deck()
c.shuffle()
c2 = c.dealCard()
c2.getRank(), c2.getSuit()