Hi,
I have the following code working fine. What I would like to try is when n cards are randomly selected, to print the cards in a graphics window.
I want to add a new class draw(self,win,center) that displays the card.
I have a set of bmp cards.
# Import random
from random import*
# Create the Card class
class Card:
def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
self.ranks = [None, "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"]
self.suits = ["Spades","Diamonds","clubs","hearts"]
self.BJ = [None, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
def getRank(self):
return self.rank
def getSuit(self):
return self.suit
def BJValue(self):
return 0 ## temporary
def __str__(self):
return "%s of %s (%s)" % (self.ranks[self.rank],self.suits[self.suit], self.BJ[self.rank])
def main():
print __doc__
n = input("Enter the number of cards to draw >>")
for i in range(n):
rankCard = randrange(1,13)
suitCard = randrange(0,3)
NumCards = Card(rankCard,suitCard)
if rankCard == 1:
print NumCards,"but it can be (1) also"
else:
print NumCards
Rgds
macca1111