1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
class Card( object ):
"""A single playing card, suitable for Blackjack or
Poker. While a suit is retained, it doesn't figure into
the ordering of cards, as it would in Bridge.
@note: The internal rank of an Ace is 14. The constructor,
however, expects a value of 1.
@ivar rank: the numeric rank of the card. 2-13, with ace as 14.
@ivar suit: the string suit of the card.
"""
def __init__( self, rank, suit ):
"""Build a card with a given rank and suit.
@param rank: numeric rank, ace is 1, 2-13 for 2 though King.
@type rank: C{int}
@param suit: String suit, use one of the module constants.
"""
self.rank= 14
self.suit= suit
def __str__( self ):
"""String representation for a Card.
@return: string
"""
def __cmp__( self, other ):
"""Compare the rank of two cards, ignoring suit
@param other: the other card to compare with
@return: <0 if self < other, >0 if self > other,
""" |
Partager