0
I’m doing a work of a playing card and I’m having a problem calling the class methods Deck()
, I tried to redo some parts of the code and sometimes as an undefined object, I redo it again and still nothing, someone could give me a help if possible ? thank you in advance.
Follows 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()
And what’s the problem?
– britodfbr
On leaving the program, I made a few more changes to the code
– Pedro Henrique
Solved? if yes publish the solution.
– britodfbr
I still can not solve, when I pass getTank() and getSuit() on top of object C2 it does not return me anything.
– Pedro Henrique