Решение на Тесте карти от Стефани Цакова

Обратно към всички решения

Към профила на Стефани Цакова

Резултати

  • 10 точки от тестове
  • 0 бонус точки
  • 10 точки общо
  • 16 успешни тест(а)
  • 0 неуспешни тест(а)

Код

SYMBOLS = {'2': 'Two', '3': 'Three', '4': 'Four', '5': 'Five', '6': 'Six',
'7': 'Seven', '8': 'Eight', '9': 'Nine', '10': 'Ten', 'J': 'Jack',
'Q': 'Queen', 'K': 'King', 'A': 'Ace'}
COLORS = {'Hearts': 'red', 'Spades':
'black', 'Clubs': 'black', 'Diamonds': 'red'}
class Rank(object):
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self, other):
return self.symbol == other.symbol
def __str__(self):
return SYMBOLS[self.symbol]
def __repr__(self):
return SYMBOLS[self.symbol]
class Suit(object):
def __init__(self, color):
self.color = COLORS[color]
class Ace(Rank):
def __init__(self):
Rank.__init__(self, 'A')
class Two(Rank):
def __init__(self):
Rank.__init__(self, '2')
class Three(Rank):
def __init__(self):
Rank.__init__(self, '3')
class Four(Rank):
def __init__(self):
Rank.__init__(self, '4')
class Five(Rank):
def __init__(self):
Rank.__init__(self, '5')
class Six(Rank):
def __init__(self):
Rank.__init__(self, '6')
class Seven(Rank):
def __init__(self):
Rank.__init__(self, '7')
class Eight(Rank):
def __init__(self):
Rank.__init__(self, '8')
class Nine(Rank):
def __init__(self):
Rank.__init__(self, '9')
class Ten(Rank):
def __init__(self):
Rank.__init__(self, '10')
class Jack(Rank):
def __init__(self):
Rank.__init__(self, 'J')
class Queen(Rank):
def __init__(self):
Rank.__init__(self, 'Q')
class King(Rank):
def __init__(self):
Rank.__init__(self, 'K')
class Hearts(Suit):
def __init__(self):
Suit.__init__(self, 'Hearts')
def __str__(self):
return 'Hearts'
def __eq__(self, other):
return str(self) == str(other)
class Spades(Suit):
def __init__(self):
Suit.__init__(self, 'Spades')
def __str__(self):
return 'Spades'
def __eq__(self, other):
return str(self) == str(other)
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self, 'Diamonds')
def __str__(self):
return 'Diamonds'
def __eq__(self, other):
return str(self) == str(other)
class Clubs(Suit):
def __init__(self):
Suit.__init__(self, 'Clubs')
def __str__(self):
return 'Clubs'
def __eq__(self, other):
return str(self) == str(other)
ALL_RANKS = ['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight',
'Seven', 'Six', 'Five', 'Four', 'Three', 'Two', 'Ace']
ALL_SUITS = ['Diamonds', 'Clubs', 'Hearts', 'Spades']
RANKS = dict((item, globals()[item]) for item in ALL_RANKS)
SUITS = dict((item, globals()[item]) for item in ALL_SUITS)
class Card(object):
def __init__(self, rank, suit):
self._rank = rank()
self._suit = suit()
def __eq__(self, other):
return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return str(self.rank) + " of " + str(self.suit)
def __repr__(self):
return "<Card %s of %s>" % (self.rank, self.suit)
@property
def rank(self):
return self._rank
@property
def suit(self):
return self._suit
class CardCollection:
def __init__(self, collection=[]):
self.collection = list(collection)
def __getitem__(self, index):
return self.collection[index]
def __len__(self):
return len(self.collection)
def __repr__(self):
return str([item for item in self.collection])
def __iter__(self):
return iter(self.collection)
def add(self, card):
self.collection.append(card)
def draw(self, index):
wanted_card = self.collection[index]
del self.collection[index]
return wanted_card
def draw_from_top(self):
return self.collection.pop()
def draw_from_bottom(self):
return self.collection.pop(0)
def top_card(self):
return self.collection[len(self.collection) - 1]
def bottom_card(self):
return self.collection[0]
def index(self, card):
return self.collection.index(card)
def StandardDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS])
def BeloteDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS
if rank not in ALL_RANKS[7:12]])
def SixtySixDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS
if rank not in ALL_RANKS[5:12]])

Лог от изпълнението

................
----------------------------------------------------------------------
Ran 16 tests in 0.023s

OK

История (4 версии и 4 коментара)

Стефани обнови решението на 21.03.2014 11:27 (преди около 10 години)

+import itertools
+import random
+
+
+def random_card():
+ return Card(random.choice(list(RANKS.values())),
+ random.choice(list(SUITS.values())))
+
+SYMBOLS = {'2': 'Two', '3': 'Three', '4': 'Four', '5': 'Five', '6': 'Six',
+ '7': 'Seven', '8': 'Eight', '9': 'Nine', '10': 'Ten', 'J': 'Jack',
+ 'Q': 'Queen', 'K': 'King', 'A': 'Ace'}
+
+COLORS = {'Hearts': 'red', 'Spades':
+ 'black', 'Clubs': 'black', 'Diamonds': 'red'}
+
+class Rank(object):
+
+ def __init__(self, symbol):
+ self.symbol = symbol
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return SYMBOLS[self.symbol]
+
+ def __repr__(self):
+ return SYMBOLS[self.symbol]
+
+
+class Suit(object):
+
+ def __init__(self, color):
+ self.color = COLORS[color]
+
+ def __eq__(self, other):
+ return self.color == other.color
+
+
+class Ace(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'A')
+
+
+class Two(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, '2')
+
+
+class Three(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, '3')
+
+
+class Four(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, '4')
+
+
+class Five(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, '5')
+
+
+class Six(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, '6')
+
+
+class Seven(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, '7')
+
+
+class Eight(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, '8')
+
+
+class Nine(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, '9')
+
+
+class Ten(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, '10')
+
+
+class Jack(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'J')
+
+
+class Queen(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'Q')
+
+
+class King(Rank):
+
+ def __init__(self):
+ Rank.__init__(self, 'K')
+
+
+class Hearts(Suit):
+
+ def __init__(self):
+ Suit.__init__(self, 'Hearts')
+
+ def __str__(self):
+ return 'Hearts'
+
+
+class Spades(Suit):
+
+ def __init__(self):
+ Suit.__init__(self, 'Spades')
+
+ def __str__(self):
+ return 'Spades'
+
+
+class Diamonds(Suit):
+
+ def __init__(self):
+ Suit.__init__(self, 'Diamonds')
+
+ def __str__(self):
+ return 'Diamonds'
+
+
+class Clubs(Suit):
+
+ def __init__(self):
+ Suit.__init__(self, 'Clubs')
+
+ def __str__(self):
+ return 'Clubs'
+
+
+ALL_RANKS = ['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight',
+ 'Seven', 'Six', 'Five', 'Four', 'Three', 'Two', 'Ace']
+
+ALL_SUITS = ['Diamonds', 'Clubs', 'Hearts', 'Spades']
+
+RANKS = dict((item, eval(item)) for item in ALL_RANKS)
+SUITS = dict((item, eval(item)) for item in ALL_SUITS)
+
+class Card(object):
+
+ def __init__(self, rank, suit):
+ self._rank = rank()
+ self._suit = suit()
+
+ def __eq__(self, other):
+ return self.rank == other.rank and self.suit == other.suit
+
+ def __str__(self):
+ return str(self.rank) + " of " + str(self.suit)
+
+ def __repr__(self):
+ return "<Card %s of %s>" % (self.rank, self.suit)
+
+ @property
+ def rank(self):
+ return self._rank
+
+ @property
+ def suit(self):
+ return self._suit
+
+
+class CardCollection:
+
+ def __init__(self, collection=[]):
+ self.collection = list(collection)
+
+ def __getitem__(self, index):
+ return self.collection[index]
+
+ def __len__(self):
+ return len(self.collection)
+
+ def __repr__(self):
+ return str([item for item in self.collection])
+
+ def add(self, card):
+ self.collection.append(card)
+
+ def draw(self, index):
+ wanted_card = self.collection[index]
+ del self.collection[index]
+ return wanted_card
+
+ def draw_from_top(self):
+ return self.collection.pop()
+
+ def draw_from_bottom(self):
+ return self.collection.pop(0)
+
+ def top_card(self):
+ return self.collection[len(self.collection) - 1]
+
+ def bottom_card(self):
+ return self.collection[0]
+
+ def index(self, card):
+ return self.collection.index(card)
+
+
+def StandardDeck():
+ return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
+ for rank in ALL_RANKS])
+
+
+def BeloteDeck():
+ return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
+ for rank in ALL_RANKS
+ if rank not in ALL_RANKS[7:12]])
+
+
+def SixtySixDeck():
+ return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
+ for rank in ALL_RANKS
+ if rank not in ALL_RANKS[5:12]])

Стефани обнови решението на 21.03.2014 11:35 (преди около 10 години)

-import itertools
-import random
-
-
-def random_card():
- return Card(random.choice(list(RANKS.values())),
- random.choice(list(SUITS.values())))
-
SYMBOLS = {'2': 'Two', '3': 'Three', '4': 'Four', '5': 'Five', '6': 'Six',
'7': 'Seven', '8': 'Eight', '9': 'Nine', '10': 'Ten', 'J': 'Jack',
'Q': 'Queen', 'K': 'King', 'A': 'Ace'}
COLORS = {'Hearts': 'red', 'Spades':
'black', 'Clubs': 'black', 'Diamonds': 'red'}
+
class Rank(object):
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self, other):
return self.symbol == other.symbol
def __str__(self):
return SYMBOLS[self.symbol]
def __repr__(self):
return SYMBOLS[self.symbol]
class Suit(object):
def __init__(self, color):
self.color = COLORS[color]
def __eq__(self, other):
return self.color == other.color
class Ace(Rank):
def __init__(self):
Rank.__init__(self, 'A')
class Two(Rank):
def __init__(self):
Rank.__init__(self, '2')
class Three(Rank):
def __init__(self):
Rank.__init__(self, '3')
class Four(Rank):
def __init__(self):
Rank.__init__(self, '4')
class Five(Rank):
def __init__(self):
Rank.__init__(self, '5')
class Six(Rank):
def __init__(self):
Rank.__init__(self, '6')
class Seven(Rank):
def __init__(self):
Rank.__init__(self, '7')
class Eight(Rank):
def __init__(self):
Rank.__init__(self, '8')
class Nine(Rank):
def __init__(self):
Rank.__init__(self, '9')
class Ten(Rank):
def __init__(self):
Rank.__init__(self, '10')
class Jack(Rank):
def __init__(self):
Rank.__init__(self, 'J')
class Queen(Rank):
def __init__(self):
Rank.__init__(self, 'Q')
class King(Rank):
def __init__(self):
Rank.__init__(self, 'K')
class Hearts(Suit):
def __init__(self):
Suit.__init__(self, 'Hearts')
def __str__(self):
return 'Hearts'
class Spades(Suit):
def __init__(self):
Suit.__init__(self, 'Spades')
def __str__(self):
return 'Spades'
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self, 'Diamonds')
def __str__(self):
return 'Diamonds'
class Clubs(Suit):
def __init__(self):
Suit.__init__(self, 'Clubs')
def __str__(self):
return 'Clubs'
ALL_RANKS = ['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight',
'Seven', 'Six', 'Five', 'Four', 'Three', 'Two', 'Ace']
ALL_SUITS = ['Diamonds', 'Clubs', 'Hearts', 'Spades']
RANKS = dict((item, eval(item)) for item in ALL_RANKS)
SUITS = dict((item, eval(item)) for item in ALL_SUITS)
+
class Card(object):
def __init__(self, rank, suit):
self._rank = rank()
self._suit = suit()
def __eq__(self, other):
return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return str(self.rank) + " of " + str(self.suit)
def __repr__(self):
return "<Card %s of %s>" % (self.rank, self.suit)
@property
def rank(self):
return self._rank
@property
def suit(self):
return self._suit
class CardCollection:
def __init__(self, collection=[]):
self.collection = list(collection)
def __getitem__(self, index):
return self.collection[index]
def __len__(self):
return len(self.collection)
def __repr__(self):
return str([item for item in self.collection])
def add(self, card):
self.collection.append(card)
def draw(self, index):
wanted_card = self.collection[index]
del self.collection[index]
return wanted_card
def draw_from_top(self):
return self.collection.pop()
def draw_from_bottom(self):
return self.collection.pop(0)
def top_card(self):
return self.collection[len(self.collection) - 1]
def bottom_card(self):
return self.collection[0]
def index(self, card):
return self.collection.index(card)
def StandardDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS])
def BeloteDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS
if rank not in ALL_RANKS[7:12]])
def SixtySixDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS
if rank not in ALL_RANKS[5:12]])

относно type()

  • King = type('King', (Rank,), {'__init__': Rank.__init__('K')})

  • King = type('King', (Rank,), {'__init__': functools.partial(Rank.__init__, symbol='A')})

  • и много други, които опитах

Нито едно от въпросните не присвоява на symbol стойността 'К' и съответно нататък нищо не става.

Не е задължително да добавяш атрибутите си в конструктора, може и така:

class King:
    symbol = 'K'
    swag = 1337
    wives = 0
    def __init__(self, name):
        self.name = name

Така дефинирани атрибутите могат и да се достъпват от класа.

>>> King.symbol
'K'
>>> King.name # няма го

съответно с type:

>>> type('King', (Rank, ), {'symbol': 'K', '__init__': '...'}

Иначе, така както се опитваше да го направиш би се сработило така:

>>> King = type('King', (Rank,), {'__init__': lambda self: Rank.__init__('K')})

За lambda ще говорим по-късно, но е начин да направиш функция която е безименна и е на само един ред.

King = type('King', (Rank,), {'__init__': lambda self: Rank.__init__('K')}) така също не се получаваше, но с

  • King = type('King', (Rank,), {'__init__': lambda self: Rank.__init__(self,'K')}) става.

Edit: Оправих locals(), но с type се получава някакъв бъг и ще изчакам решенията на другите да видя къде е проблемът.

Стефани обнови решението на 25.03.2014 23:11 (преди около 10 години)

SYMBOLS = {'2': 'Two', '3': 'Three', '4': 'Four', '5': 'Five', '6': 'Six',
'7': 'Seven', '8': 'Eight', '9': 'Nine', '10': 'Ten', 'J': 'Jack',
'Q': 'Queen', 'K': 'King', 'A': 'Ace'}
COLORS = {'Hearts': 'red', 'Spades':
'black', 'Clubs': 'black', 'Diamonds': 'red'}
class Rank(object):
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self, other):
return self.symbol == other.symbol
def __str__(self):
return SYMBOLS[self.symbol]
def __repr__(self):
return SYMBOLS[self.symbol]
class Suit(object):
def __init__(self, color):
self.color = COLORS[color]
def __eq__(self, other):
return self.color == other.color
class Ace(Rank):
def __init__(self):
Rank.__init__(self, 'A')
class Two(Rank):
def __init__(self):
Rank.__init__(self, '2')
class Three(Rank):
def __init__(self):
Rank.__init__(self, '3')
class Four(Rank):
def __init__(self):
Rank.__init__(self, '4')
class Five(Rank):
def __init__(self):
Rank.__init__(self, '5')
class Six(Rank):
def __init__(self):
Rank.__init__(self, '6')
class Seven(Rank):
def __init__(self):
Rank.__init__(self, '7')
class Eight(Rank):
def __init__(self):
Rank.__init__(self, '8')
class Nine(Rank):
def __init__(self):
Rank.__init__(self, '9')
class Ten(Rank):
def __init__(self):
Rank.__init__(self, '10')
class Jack(Rank):
def __init__(self):
Rank.__init__(self, 'J')
class Queen(Rank):
def __init__(self):
Rank.__init__(self, 'Q')
class King(Rank):
def __init__(self):
Rank.__init__(self, 'K')
class Hearts(Suit):
def __init__(self):
Suit.__init__(self, 'Hearts')
def __str__(self):
return 'Hearts'
class Spades(Suit):
def __init__(self):
Suit.__init__(self, 'Spades')
def __str__(self):
return 'Spades'
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self, 'Diamonds')
def __str__(self):
return 'Diamonds'
class Clubs(Suit):
def __init__(self):
Suit.__init__(self, 'Clubs')
def __str__(self):
return 'Clubs'
ALL_RANKS = ['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight',
'Seven', 'Six', 'Five', 'Four', 'Three', 'Two', 'Ace']
ALL_SUITS = ['Diamonds', 'Clubs', 'Hearts', 'Spades']
-RANKS = dict((item, eval(item)) for item in ALL_RANKS)
-SUITS = dict((item, eval(item)) for item in ALL_SUITS)
+RANKS = dict((item, globals()[item]) for item in ALL_RANKS)
+SUITS = dict((item, globals()[item]) for item in ALL_SUITS)
class Card(object):
def __init__(self, rank, suit):
self._rank = rank()
self._suit = suit()
def __eq__(self, other):
return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return str(self.rank) + " of " + str(self.suit)
def __repr__(self):
return "<Card %s of %s>" % (self.rank, self.suit)
@property
def rank(self):
return self._rank
@property
def suit(self):
return self._suit
class CardCollection:
def __init__(self, collection=[]):
self.collection = list(collection)
def __getitem__(self, index):
return self.collection[index]
def __len__(self):
return len(self.collection)
def __repr__(self):
return str([item for item in self.collection])
def add(self, card):
self.collection.append(card)
def draw(self, index):
wanted_card = self.collection[index]
del self.collection[index]
return wanted_card
def draw_from_top(self):
return self.collection.pop()
def draw_from_bottom(self):
return self.collection.pop(0)
def top_card(self):
return self.collection[len(self.collection) - 1]
def bottom_card(self):
return self.collection[0]
def index(self, card):
return self.collection.index(card)
def StandardDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS])
def BeloteDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS
if rank not in ALL_RANKS[7:12]])
def SixtySixDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS
if rank not in ALL_RANKS[5:12]])

Стефани обнови решението на 26.03.2014 01:34 (преди около 10 години)

SYMBOLS = {'2': 'Two', '3': 'Three', '4': 'Four', '5': 'Five', '6': 'Six',
'7': 'Seven', '8': 'Eight', '9': 'Nine', '10': 'Ten', 'J': 'Jack',
'Q': 'Queen', 'K': 'King', 'A': 'Ace'}
COLORS = {'Hearts': 'red', 'Spades':
'black', 'Clubs': 'black', 'Diamonds': 'red'}
class Rank(object):
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self, other):
return self.symbol == other.symbol
def __str__(self):
return SYMBOLS[self.symbol]
def __repr__(self):
return SYMBOLS[self.symbol]
class Suit(object):
def __init__(self, color):
self.color = COLORS[color]
- def __eq__(self, other):
- return self.color == other.color
-
class Ace(Rank):
def __init__(self):
Rank.__init__(self, 'A')
class Two(Rank):
def __init__(self):
Rank.__init__(self, '2')
class Three(Rank):
def __init__(self):
Rank.__init__(self, '3')
class Four(Rank):
def __init__(self):
Rank.__init__(self, '4')
class Five(Rank):
def __init__(self):
Rank.__init__(self, '5')
class Six(Rank):
def __init__(self):
Rank.__init__(self, '6')
class Seven(Rank):
def __init__(self):
Rank.__init__(self, '7')
class Eight(Rank):
def __init__(self):
Rank.__init__(self, '8')
class Nine(Rank):
def __init__(self):
Rank.__init__(self, '9')
class Ten(Rank):
def __init__(self):
Rank.__init__(self, '10')
class Jack(Rank):
def __init__(self):
Rank.__init__(self, 'J')
class Queen(Rank):
def __init__(self):
Rank.__init__(self, 'Q')
class King(Rank):
def __init__(self):
Rank.__init__(self, 'K')
class Hearts(Suit):
def __init__(self):
Suit.__init__(self, 'Hearts')
def __str__(self):
return 'Hearts'
+ def __eq__(self, other):
+ return str(self) == str(other)
+
class Spades(Suit):
def __init__(self):
Suit.__init__(self, 'Spades')
def __str__(self):
return 'Spades'
+ def __eq__(self, other):
+ return str(self) == str(other)
+
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self, 'Diamonds')
def __str__(self):
return 'Diamonds'
+ def __eq__(self, other):
+ return str(self) == str(other)
+
class Clubs(Suit):
def __init__(self):
Suit.__init__(self, 'Clubs')
def __str__(self):
return 'Clubs'
+ def __eq__(self, other):
+ return str(self) == str(other)
+
ALL_RANKS = ['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight',
'Seven', 'Six', 'Five', 'Four', 'Three', 'Two', 'Ace']
ALL_SUITS = ['Diamonds', 'Clubs', 'Hearts', 'Spades']
RANKS = dict((item, globals()[item]) for item in ALL_RANKS)
SUITS = dict((item, globals()[item]) for item in ALL_SUITS)
class Card(object):
def __init__(self, rank, suit):
self._rank = rank()
self._suit = suit()
def __eq__(self, other):
return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return str(self.rank) + " of " + str(self.suit)
def __repr__(self):
return "<Card %s of %s>" % (self.rank, self.suit)
@property
def rank(self):
return self._rank
@property
def suit(self):
return self._suit
class CardCollection:
def __init__(self, collection=[]):
self.collection = list(collection)
def __getitem__(self, index):
return self.collection[index]
def __len__(self):
return len(self.collection)
def __repr__(self):
return str([item for item in self.collection])
+
+ def __iter__(self):
+ return iter(self.collection)
def add(self, card):
self.collection.append(card)
def draw(self, index):
wanted_card = self.collection[index]
del self.collection[index]
return wanted_card
def draw_from_top(self):
return self.collection.pop()
def draw_from_bottom(self):
return self.collection.pop(0)
def top_card(self):
return self.collection[len(self.collection) - 1]
def bottom_card(self):
return self.collection[0]
def index(self, card):
return self.collection.index(card)
def StandardDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS])
def BeloteDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS
if rank not in ALL_RANKS[7:12]])
def SixtySixDeck():
return CardCollection([Card(RANKS[rank], SUITS[suit]) for suit in ALL_SUITS
for rank in ALL_RANKS
if rank not in ALL_RANKS[5:12]])