Кирил обнови решението на 24.03.2014 00:29 (преди над 10 години)
+
+
+
+
+class Rank:
+ _symbol = []
+
+ def __init__(self, card_symbol):
+ self._symbol = card_symbol
+
+ def __eq__(self, other):
+ return self._symbol == other._symbol
+
+ def __str__(self):
+ return self._symbol
+
+
+class Suit:
+ __color = []
+
+ def __init__(self, card_color):
+ self.__color = card_color
+
+ def __eq__(self,other):
+ return self.__color == other.__color
+
+ def __str__(self):
+ return self.__color
+
+
+
+class Two(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Two')
+
+
+class Three(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Three')
+
+
+class Four(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Four')
+
+
+class Five(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Five')
+
+
+class Six(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Six')
+
+
+class Seven(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Seven')
+
+
+class Eight(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Eight')
+
+
+class Nine(Rank):
+
+ def __init__(self):
+ Rank.__init__(self,'Nine')
+
+
+class Ten(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Ten')
+
+
+class King(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'King')
+
+
+class Jack(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Jack')
+
+
+class Queen(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Queen')
+
+
+class Ace(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Ace')
+
+
+
+
+
+class Clubs(Suit):
+
+ def __init__(self):
+ Suit.__init__(self, 'Clubs')
+
+
+class Diamonds(Suit):
+
+ def __init__(self):
+ Suit.__init__(self, 'Diamonds')
+
+
+class Hearts(Suit):
+
+ def __init__(self):
+ Suit.__init__(self, 'Hearts')
+
+
+class Spades(Suit):
+
+ def __init__(self):
+ Suit.__init__(self, 'Spades')
+
+
+RANKS = {'Queen': Queen, 'Ace': Ace, 'Two': Two,
+'Seven': Seven, 'Jack': Jack, 'Three': Three, 'Five': Five,
+'Six': Six, 'Four': Four, 'Nine': Nine, 'King': King, 'Ten': Ten,
+'Eight': Eight}
+
+SUITS = {'Clubs': Clubs, 'Diamonds': Diamonds,
+ 'Hearts': Hearts, 'Spades': Spades}
+
+class Card(Rank, Suit):
+ rank = []
+ suit = []
+
+ def __init__(self, rank, suit):
+ self.rank = rank()
+ self.suit = suit()
+ # def __getattr__(self,name):
+ # if name == ran
+
+ def __str__(self):
+ return '{} of {}'.format(self.rank, self.suit)
+
+ def __eq__(self, other):
+ return self.rank == other.rank and self.suit == other.suit
+
+
+class CardCollection(Card):
+ collection_cards = []
+
+ def __init__(self, collection):
+ self.collection_cards = collection
+
+ def draw(self, index):
+ ret_card = self.collection_cards[index]
+ self.collection_cards.pop(index)
+ return ret_card
+
+ def draw_from_top(self):
+ ret_card = self.collection_cards[len(self.collection_cards) - 1]
+ self.collection_cards.pop(len(self.collection_cards) - 1)
+ return ret_card
+
+ def draw_from_bottom(self):
+ ret_card = self.collection_cards[0]
+ self.collection_cards.pop(0)
+ return ret_card
+
+ def top_card(self):
+ return self.collection_cards[len(self.collection_cards) - 1]
+
+ def bottom_card(self):
+ return self.collection_cards[0]
+
+ def add(self, card):
+ self.collection_cards.append(card)
+
+ def index(self, card):
+ return self.collection_cards.index(card)
+
+ def __getitem__(self, index):
+ return str(self.collection_cards[index])
+
+def StandardDeck():
+ deck = [Card(rank, suit) for rank in RANKS.values()
+ for suit in SUITS.values()]
+ return deck
+def BeloteDeck():
+ deck = []
+ for suit in SUITS.values():
+ for rank in RANKS.values():
+ if Card(rank,suit) not in [Card(RANKS['Two'],suit),Card(RANKS['Three'],suit),
+ Card(RANKS['Four'],suit),Card(RANKS['Five'],suit),Card(RANKS['Six'],suit)] :
+ deck.append(Card(rank,suit))
+ return deck
+
+def SixtySixDeck():
+ deck = []
+ for suit in SUITS.values():
+ for rank in RANKS.values():
+ if Card(rank, suit) not in [Card(RANKS['Two'], suit), Card(RANKS['Three'], suit),
+ Card(RANKS['Four'], suit), Card(RANKS['Five'], suit), Card(RANKS['Six'], suit), Card(RANKS['Seven'], suit), Card(RANKS['Eight'], suit)]:
+ deck.append(Card(rank, suit))
+ print(1)
+ return deck
+
+deck = [Card(rank, suit) for rank in RANKS.values()
+ for suit in SUITS.values()]
+
+
+
+
+
+
+
+
+
+
Махни това от ред 220. Не забравяй да си махаш кода с който си тестваш защото може да ни попречи на оценяването.
Освен това си погледни стандартните тестета -- всеки път изкарват картите в различен ред ;)