Йончо обнови решението на 25.03.2014 23:22 (преди над 10 години)
+class Rank:
+
+ '''
+ The class holds the the type card representation
+ '''
+
+ symbol = None # символът на картата (A, 2, Q, K)
+
+ def __init__(self, symbol=None):
+ self.symbol = suit
+
+ def __str__(self):
+ """Returns a human-readable string representation."""
+ return Rank.__name__
+
+
+class Ace(Rank):
+
+ def __init__(self, symbol='A'):
+ self.symbol = suit
+
+
+class Two(Rank):
+
+ def __init__(self, symbol='2'):
+ self.symbol = suit
+
+
+class Three(Rank):
+
+ def __init__(self, symbol='3'):
+ self.symbol = suit
+
+
+class Four(Rank):
+
+ def __init__(self, symbol='4'):
+ self.symbol = suit
+
+
+class Five(Rank):
+
+ def __init__(self, symbol='5'):
+ self.symbol = suit
+
+
+class Six(Rank):
+
+ def __init__(self, symbol='6'):
+ self.symbol = suit
+
+
+class Seven(Rank):
+
+ def __init__(self, symbol='7'):
+ self.symbol = suit
+
+
+class Eight(Rank):
+
+ def __init__(self, symbol='8'):
+ self.symbol = suit
+
+
+class Nine(Rank):
+
+ def __init__(self, symbol='9'):
+ self.symbol = suit
+
+
+class Ten(Rank):
+
+ def __init__(self, symbol='10'):
+ self.symbol = suit
+
+
+class Jack(Rank):
+
+ def __init__(self, symbol='J'):
+ self.symbol = suit
+
+
+class Queen(Rank):
+
+ def __init__(self, symbol='Q'):
+ self.symbol = suit
+
+
+class King(Rank):
+
+ def __init__(self, symbol='Q'):
+ self.symbol = suit
+
+
+class Suit:
+
+ '''
+ The class holds the the color card representation
+ '''
+ color = None # цветът на боята ('red', 'black')
+
+ def __init__(self, color=None):
+ self.color = colorcolor
+
+ def __str__(self):
+ """Returns a human-readable string representation."""
+ return Rank.__name__
+ 'Diamonds', '', '', ''
+
+
+class Diamonds(Suit):
+
+ def __init__(self, color='red'):
+ self.color = suit
+
+
+class Hearts(Suit):
+
+ def __init__(self, color='red'):
+ self.color = suit
+
+
+class Spades(Suit):
+
+ def __init__(self, color='black'):
+ self.color = suit
+
+
+class Clubs(Suit):
+
+ def __init__(self, color='black'):
+ self.color = suit
+
+RANKS = {
+ 'King': King, 'Six': Six, 'Jack': Jack, 'Five': Five, 'Queen': Queen,
+ 'Ten': Ten, 'Ace': Ace, 'Three': Three, 'Eight': Eight, 'Four': Four,
+ 'Two': Two, 'Seven': Seven, 'Nine': Nine}
+
+SUITS = {'Diamonds': Diamonds, 'Hearts':
+ Hearts, 'Spades': Spades, 'Clubs': Clubs}
+
+
+class Card(object):
+
+ '''Represents a standard playing card.
+ Attributes:
+ suits-dictionary of suits
+ ranks-dictionary of ranks
+ '''
+
+ def __init__(self, rank, suit):
+ self.rank = RANKS[rank]
+ self.suit = SUITS[suit]
+
+ def __str__(self):
+ return '%s of %s' % (str(RANKS[rank]),
+ str(SUITS[suit]))
+
+ def __cmp__(self, other):
+ '''simple function
+ '''
+
+
+class CardCollection:
+
+ '''Represents a deck of cards.
+
+ Attributes:
+ cards: list of Card objects.
+ '''
+ deck = []
+
+ def __init__(self):
+ self.deck = []
+ for suit in SUITS.keys():
+ for rank in RANKS.keys():
+ card = Card(SUITS[suit], RANKS[rank])
+ self.deck.append(card)
+
+ def __str__(self):
+ res = []
+ for card in self.deck:
+ res.append(str(card))
+ return '\n'.join(res)
+
+ def draw(self, index):
+ return deck[index]
+
+ def draw_from_top(self):
+ return deck[0]
+
+ def draw_from_bottom(self):
+ return deck[len(deck) - 1]
+
+ def top_card(self):
+ return deck[0]
+
+ def bottom_card(self):
+ return deck[len(deck) - 1]
+
+ def add(self, card):
+ deck.add(card)
+
+ def index(self, card):
+ return deck[index]
+
+ def StandardDeck(self):
+ return deck
+
+ def BeloteDeck(self):
+ RANKS.remove('Two')
+ RANKS.remove('Three')
+ RANKS.remove('Four')
+ RANKS.remove('Five')
+ RANKS.remove('Six')
+ deck = CardCollection()
+
+ def SixtySixDeck(self):
+ RANKS.remove('Two')
+ RANKS.remove('Three')
+ RANKS.remove('Four')
+ RANKS.remove('Five')
+ RANKS.remove('Six')
+ RANKS.remove('Seven')
+ RANKS.remove('Eight')
+ deck = CardCollection()