Решение на Тесте карти от Пламен Димитров

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

Към профила на Пламен Димитров

Резултати

  • 8 точки от тестове
  • 0 бонус точки
  • 8 точки общо
  • 13 успешни тест(а)
  • 3 неуспешни тест(а)

Код

class Rank():
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self, right):
return self.symbol == right.symbol
def __str__(self):
return type(self).__name__
class King(Rank):
def __init__(self):
Rank.__init__(self, "K")
class Queen(Rank):
def __init__(self):
Rank.__init__(self, "Q")
class Jack(Rank):
def __init__(self):
Rank.__init__(self, "J")
class Ten(Rank):
def __init__(self):
Rank.__init__(self, "10")
class Nine(Rank):
def __init__(self):
Rank.__init__(self, "9")
class Eight(Rank):
def __init__(self):
Rank.__init__(self, "8")
class Seven(Rank):
def __init__(self):
Rank.__init__(self, "7")
class Six(Rank):
def __init__(self):
Rank.__init__(self, "6")
class Five(Rank):
def __init__(self):
Rank.__init__(self, "5")
class Four(Rank):
def __init__(self):
Rank.__init__(self, "4")
class Three(Rank):
def __init__(self):
Rank.__init__(self, "3")
class Two(Rank):
def __init__(self):
Rank.__init__(self, "2")
class Ace(Rank):
def __init__(self):
Rank.__init__(self, "A")
RANKS = {"King": King, "Queen": Queen, "Jack": Jack, "Ten": Ten, "Nine": Nine,
"Eight": Eight, "Seven": Seven, "Six": Six, "Five": Five, "Four": Four,
"Three": Three, "Two": Two, "Ace": Ace}
TYPES_OF_RANK = [King, Queen, Jack, Ten, Nine, Eight, Seven, Six, Five, Four,
Three, Two, Ace]
class Suit():
def __init__(self, color):
self.color = color
def __eq__(self, right):
return type(self) == type(right)
def __str__(self):
return type(self).__name__
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self, "red")
class Clubs(Suit):
def __init__(self):
Suit.__init__(self, "black")
class Hearts(Suit):
def __init__(self):
Suit.__init__(self, "red")
class Spades(Suit):
def __init__(self):
Suit.__init__(self, "black")
SUITS = {"Diamonds": Diamonds, "Clubs": Clubs, "Hearts": Hearts,
"Spades": Spades}
TYPES_OF_SUITS = [Diamonds, Clubs, Hearts, Spades]
class Card():
def __init__(self, rank, suit):
object.__setattr__(self, "rank", rank())
object.__setattr__(self, "suit", suit())
def __setattr__(self, *args):
raise Exception("can't set atribute")
def __eq__(self, right):
return self.suit == right.suit and self.rank == right.rank
def __str__(self):
return '{0} of {1}'.format(self.rank, self.suit)
class CardCollection():
def __init__(self, collection=[]):
self.collection = [card for card in collection]
def draw(self, index):
card = Card(self.collection[index].rank, self.collection[index].suit)
del self.collection[index]
return card
def draw_from_top(self):
card = Card(self.collection[-1].rank.__class__,
self.collection[-1].suit.__class__)
del self.collection[-1]
return card
def draw_from_bottom(self):
card = Card(self.collection[0].rank, self.collection[0].suit)
del self.collection[0]
return card
def top_card(self):
return self.collection[-1]
def bottom_card(self):
return self.collection[0]
def index(self, card):
return self.collection.index(card)
def __getitem__(self, index):
return self.collection[index]
def add(self, card):
self.collection.append(card)
def __len__(self):
return len(self.collection)
def StandardDeck():
card_collection = []
for suit in TYPES_OF_SUITS:
for rank in TYPES_OF_RANK:
card_collection.append(Card(rank, suit))
return card_collection
def BeloteDeck():
card_collection = []
for suit in TYPES_OF_SUITS:
for rank in TYPES_OF_RANK:
if rank == RANKS["Six"]:
break
card_collection.append(Card(rank, suit))
card_collection.append(Card(TYPES_OF_RANK[-1], TYPES_OF_SUITS[-1]))
return card_collection
def SixtySixDeck():
card_collection = []
for suit in TYPES_OF_SUITS:
for rank in TYPES_OF_RANK:
if rank == RANKS["Eight"]:
break
card_collection.append(Card(rank, suit))
card_collection.append(Card(TYPES_OF_RANK[-1], TYPES_OF_SUITS[-1]))
return card_collection

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

F.E...F.........
======================================================================
ERROR: test_deck_draw (test.CardCollectionTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140407-19315-czcf6l/test.py", line 145, in test_deck_draw
    self.assertEqual(card, deck.draw_from_bottom())
  File "/tmp/d20140407-19315-czcf6l/solution.py", line 149, in draw_from_bottom
    card = Card(self.collection[0].rank, self.collection[0].suit)
  File "/tmp/d20140407-19315-czcf6l/solution.py", line 120, in __init__
    object.__setattr__(self, "rank", rank())
TypeError: 'Nine' object is not callable

======================================================================
FAIL: test_belote_deck (test.CardCollectionTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140407-19315-czcf6l/test.py", line 175, in test_belote_deck
    self.assertEqual(BELOTE_DECK, cards)
AssertionError: Lists differ: ['King of Diamonds', 'Queen of... != ['King of Diamonds', 'Queen of...

First differing element 7:
Ace of Diamonds
King of Clubs

First list contains 3 additional elements.
First extra element 29:
Eight of Spades

Diff is 684 characters long. Set self.maxDiff to None to see it.

======================================================================
FAIL: test_sixtysix_deck (test.CardCollectionTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140407-19315-czcf6l/test.py", line 179, in test_sixtysix_deck
    self.assertEqual(SIXTY_SIX_DECK, cards)
AssertionError: Lists differ: ['King of Diamonds', 'Queen of... != ['King of Diamonds', 'Queen of...

First differing element 5:
Ace of Diamonds
King of Clubs

First list contains 3 additional elements.
First extra element 21:
Ten of Spades

  ['King of Diamonds',
   'Queen of Diamonds',
   'Jack of Diamonds',
   'Ten of Diamonds',
   'Nine of Diamonds',
-  'Ace of Diamonds',
   'King of Clubs',
   'Queen of Clubs',
   'Jack of Clubs',
   'Ten of Clubs',
   'Nine of Clubs',
-  'Ace of Clubs',
   'King of Hearts',
   'Queen of Hearts',
   'Jack of Hearts',
   'Ten of Hearts',
   'Nine of Hearts',
-  'Ace of Hearts',
   'King of Spades',
   'Queen of Spades',
   'Jack of Spades',
   'Ten of Spades',
   'Nine of Spades',
   'Ace of Spades']

----------------------------------------------------------------------
Ran 16 tests in 0.032s

FAILED (failures=2, errors=1)

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

Пламен обнови решението на 24.03.2014 00:46 (преди около 10 години)

+class Rank():
+ def __init__(self, symbol):
+ self.symbol = symbol
+
+ def __eq__(self, ight):
+ return self.symbol == right.symbol
+
+ def __str__(self):
+ return type(self).__name__
+
+RANKS = {}
+TYPES_OF_RANK = []
+
+
+class King(Rank):
+ def __init__(self):
+ Rank.__init__(self, "K")
+
+RANKS["King"] = type(King())
+TYPES_OF_RANK.append(RANKS["King"])
+
+
+class Queen(Rank):
+ def __init__(self):
+ Rank.__init__(self, "Q")
+
+RANKS["Queen"] = type(Queen())
+TYPES_OF_RANK.append(RANKS["Queen"])
+
+
+class Jack(Rank):
+ def __init__(self):
+ Rank.__init__(self, "J")
+
+RANKS["Jack"] = type(Jack())
+TYPES_OF_RANK.append(RANKS["Jack"])
+
+
+class Ten(Rank):
+ def __init__(self):
+ Rank.__init__(self, "10")
+
+RANKS["Ten"] = type(Ten())
+TYPES_OF_RANK.append(RANKS["Ten"])
+
+
+class Nine(Rank):
+ def __init__(self):
+ Rank.__init__(self, "9")
+
+RANKS["Nine"] = type(Nine())
+TYPES_OF_RANK.append(RANKS["Nine"])
+
+
+class Eight(Rank):
+ def __init__(self):
+ Rank.__init__(self, "8")
+
+RANKS["Eight"] = type(Eight())
+TYPES_OF_RANK.append(RANKS["Eight"])
+
+
+class Seven(Rank):
+ def __init__(self):
+ Rank.__init__(self, "7")
+
+RANKS["Seven"] = type(Seven())
+TYPES_OF_RANK.append(RANKS["Seven"])
+
+
+class Six(Rank):
+ def __init__(self):
+ Rank.__init__(self, "6")
+
+RANKS["Six"] = type(Six())
+TYPES_OF_RANK.append(RANKS["Six"])
+
+
+class Five(Rank):
+ def __init__(self):
+ Rank.__init__(self, "5")
+
+RANKS["Five"] = type(Five())
+TYPES_OF_RANK.append(RANKS["Five"])
+
+
+class Four(Rank):
+ def __init__(self):
+ Rank.__init__(self, "4")
+
+RANKS["Four"] = type(Four())
+TYPES_OF_RANK.append(RANKS["Four"])
+
+
+class Three(Rank):
+ def __init__(self):
+ Rank.__init__(self, "3")
+
+RANKS["Three"] = type(Three())
+TYPES_OF_RANK.append(RANKS["Three"])
+
+
+class Two(Rank):
+ def __init__(self):
+ Rank.__init__(self, "2")
+
+RANKS["Two"] = type(Two())
+TYPES_OF_RANK.append(RANKS["Two"])
+
+
+class Ace(Rank):
+ def __init__(self):
+ Rank.__init__(self, "A")
+
+RANKS["Ace"] = type(Ace())
+TYPES_OF_RANK.append(RANKS["Ace"])
+
+SUITS = {}
+TYPES_OF_SUITS = []
+
+
+class Suit():
+ def __init__(self, color):
+ self.color = color
+
+ def __eq__(self, right):
+ return type(self) == type(right)
+
+ def __str__(self):
+ return type(self).__name__
+
+
+class Diamonds(Suit):
+ def __init__(self):
+ Suit.__init__(self, "red")
+
+
+SUITS["Diamonds"] = type(Diamonds())
+TYPES_OF_SUITS.append(SUITS["Diamonds"])
+
+
+class Clubs(Suit):
+ def __init__(self):
+ Suit.__init__(self, "black")
+
+SUITS["Clubs"] = type(Clubs())
+TYPES_OF_SUITS.append(SUITS["Clubs"])
+
+
+class Hearts(Suit):
+ def __init__(self):
+ Suit.__init__(self, "red")
+
+SUITS["Hearts"] = type(Hearts())
+TYPES_OF_SUITS.append(SUITS["Hearts"])
+
+
+class Spades(Suit):
+ def __init__(self):
+ Suit.__init__(self, "black")
+
+
+SUITS["Spades"] = type(Spades())
+TYPES_OF_SUITS.append(SUITS["Spades"])
+
+
+class Card():
+ def __init__(self, rank, suit):
+ object.__setattr__(self, "rank", rank())
+ object.__setattr__(self, "suit", suit())
+
+ def __setattr__(self, *args):
+ raise Exception("can't set atribute")
+
+ def __eq__(self, right):
+ return self.suit == right.suit and self.rank == right.rank
+
+ def __str__(self):
+ return '{0} of {1}'.format(self.rank, self.suit)
+
+
+class CardCollection():
+ def __init__(self, collection=[]):
+ self.collection = [card for card in collection]
+
+ def draw(self, index):
+ card = Card(self.collection[index].rank, self.collection[index].suit)
+ del self.collection[index]
+ return card
+
+ def draw_from_top(self):
+ card = Card(self.collection[-1].rank.__class__,
+ self.collection[-1].suit.__class__)
+ del self.collection[-1]
+ return card
+
+ def draw_from_bottom(self):
+ card = Card(self.collection[0].rank, self.collection[0].suit)
+ del self.collection[0]
+ return card
+
+ def top_card(self):
+ return self.collection[-1]
+
+ def bottom_card(self):
+ return self.collection[0]
+
+ def index(self, card):
+ return self.collection.index(card)
+
+ def __getitem__(self, index):
+ return self.collection[index]
+
+ def add(self, card):
+ self.collection.append(card)
+
+ def __len__(self):
+ return len(self.collection)
+
+
+def StandardDeck():
+ card_collection = []
+ for suit in TYPES_OF_SUITS:
+ for rank in TYPES_OF_RANK:
+ card_collection.append(Card(rank, suit))
+ return card_collection
+
+
+def BeloteDeck():
+ card_collection = []
+ for suit in TYPES_OF_SUITS:
+ for rank in TYPES_OF_RANK:
+ if rank == RANKS["Six"]:
+ break
+ card_collection.append(Card(rank, suit))
+ return card_collection
+
+
+def SixtySixDeck():
+ card_collection = []
+ for suit in TYPES_OF_SUITS:
+ for rank in TYPES_OF_RANK:
+ if rank == RANKS["Eight"]:
+ break
+ card_collection.append(Card(rank, suit))
+ return card_collection

Пламен обнови решението на 24.03.2014 00:53 (преди около 10 години)

class Rank():
def __init__(self, symbol):
self.symbol = symbol
- def __eq__(self, ight):
+ def __eq__(self, right):
return self.symbol == right.symbol
def __str__(self):
return type(self).__name__
RANKS = {}
TYPES_OF_RANK = []
class King(Rank):
def __init__(self):
Rank.__init__(self, "K")
RANKS["King"] = type(King())
TYPES_OF_RANK.append(RANKS["King"])
class Queen(Rank):
def __init__(self):
Rank.__init__(self, "Q")
RANKS["Queen"] = type(Queen())
TYPES_OF_RANK.append(RANKS["Queen"])
class Jack(Rank):
def __init__(self):
Rank.__init__(self, "J")
RANKS["Jack"] = type(Jack())
TYPES_OF_RANK.append(RANKS["Jack"])
class Ten(Rank):
def __init__(self):
Rank.__init__(self, "10")
RANKS["Ten"] = type(Ten())
TYPES_OF_RANK.append(RANKS["Ten"])
class Nine(Rank):
def __init__(self):
Rank.__init__(self, "9")
RANKS["Nine"] = type(Nine())
TYPES_OF_RANK.append(RANKS["Nine"])
class Eight(Rank):
def __init__(self):
Rank.__init__(self, "8")
RANKS["Eight"] = type(Eight())
TYPES_OF_RANK.append(RANKS["Eight"])
class Seven(Rank):
def __init__(self):
Rank.__init__(self, "7")
RANKS["Seven"] = type(Seven())
TYPES_OF_RANK.append(RANKS["Seven"])
class Six(Rank):
def __init__(self):
Rank.__init__(self, "6")
RANKS["Six"] = type(Six())
TYPES_OF_RANK.append(RANKS["Six"])
class Five(Rank):
def __init__(self):
Rank.__init__(self, "5")
RANKS["Five"] = type(Five())
TYPES_OF_RANK.append(RANKS["Five"])
class Four(Rank):
def __init__(self):
Rank.__init__(self, "4")
RANKS["Four"] = type(Four())
TYPES_OF_RANK.append(RANKS["Four"])
class Three(Rank):
def __init__(self):
Rank.__init__(self, "3")
RANKS["Three"] = type(Three())
TYPES_OF_RANK.append(RANKS["Three"])
class Two(Rank):
def __init__(self):
Rank.__init__(self, "2")
RANKS["Two"] = type(Two())
TYPES_OF_RANK.append(RANKS["Two"])
class Ace(Rank):
def __init__(self):
Rank.__init__(self, "A")
RANKS["Ace"] = type(Ace())
TYPES_OF_RANK.append(RANKS["Ace"])
SUITS = {}
TYPES_OF_SUITS = []
class Suit():
def __init__(self, color):
self.color = color
def __eq__(self, right):
return type(self) == type(right)
def __str__(self):
return type(self).__name__
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self, "red")
SUITS["Diamonds"] = type(Diamonds())
TYPES_OF_SUITS.append(SUITS["Diamonds"])
class Clubs(Suit):
def __init__(self):
Suit.__init__(self, "black")
SUITS["Clubs"] = type(Clubs())
TYPES_OF_SUITS.append(SUITS["Clubs"])
class Hearts(Suit):
def __init__(self):
Suit.__init__(self, "red")
SUITS["Hearts"] = type(Hearts())
TYPES_OF_SUITS.append(SUITS["Hearts"])
class Spades(Suit):
def __init__(self):
Suit.__init__(self, "black")
SUITS["Spades"] = type(Spades())
TYPES_OF_SUITS.append(SUITS["Spades"])
class Card():
def __init__(self, rank, suit):
object.__setattr__(self, "rank", rank())
object.__setattr__(self, "suit", suit())
def __setattr__(self, *args):
raise Exception("can't set atribute")
def __eq__(self, right):
return self.suit == right.suit and self.rank == right.rank
def __str__(self):
return '{0} of {1}'.format(self.rank, self.suit)
class CardCollection():
def __init__(self, collection=[]):
self.collection = [card for card in collection]
def draw(self, index):
card = Card(self.collection[index].rank, self.collection[index].suit)
del self.collection[index]
return card
def draw_from_top(self):
card = Card(self.collection[-1].rank.__class__,
- self.collection[-1].suit.__class__)
+ self.collection[-1].suit.__class__)
del self.collection[-1]
return card
def draw_from_bottom(self):
card = Card(self.collection[0].rank, self.collection[0].suit)
del self.collection[0]
return card
def top_card(self):
return self.collection[-1]
def bottom_card(self):
return self.collection[0]
def index(self, card):
return self.collection.index(card)
def __getitem__(self, index):
return self.collection[index]
def add(self, card):
self.collection.append(card)
def __len__(self):
return len(self.collection)
def StandardDeck():
card_collection = []
for suit in TYPES_OF_SUITS:
for rank in TYPES_OF_RANK:
card_collection.append(Card(rank, suit))
return card_collection
def BeloteDeck():
card_collection = []
for suit in TYPES_OF_SUITS:
for rank in TYPES_OF_RANK:
if rank == RANKS["Six"]:
break
card_collection.append(Card(rank, suit))
return card_collection
def SixtySixDeck():
card_collection = []
for suit in TYPES_OF_SUITS:
for rank in TYPES_OF_RANK:
if rank == RANKS["Eight"]:
break
card_collection.append(Card(rank, suit))
return card_collection

Подсказка:

RANKS["Nine"] = type("Nine", (Rank, ), {"__init__": lambda self: Rank.__init__(self, "9")})

Прочети help(type) за да видиш защо. Но за да стане още по-кратко може и без __init__ :) Помисли как ако искаш!

Освен това имаш грешки в подредбата на тестетата за Белот и Сантасе.

Пламен обнови решението на 25.03.2014 21:50 (преди около 10 години)

class Rank():
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self, right):
return self.symbol == right.symbol
def __str__(self):
return type(self).__name__
-RANKS = {}
-TYPES_OF_RANK = []
-
class King(Rank):
def __init__(self):
Rank.__init__(self, "K")
-RANKS["King"] = type(King())
-TYPES_OF_RANK.append(RANKS["King"])
-
class Queen(Rank):
def __init__(self):
Rank.__init__(self, "Q")
-RANKS["Queen"] = type(Queen())
-TYPES_OF_RANK.append(RANKS["Queen"])
-
class Jack(Rank):
def __init__(self):
Rank.__init__(self, "J")
-RANKS["Jack"] = type(Jack())
-TYPES_OF_RANK.append(RANKS["Jack"])
-
class Ten(Rank):
def __init__(self):
Rank.__init__(self, "10")
-RANKS["Ten"] = type(Ten())
-TYPES_OF_RANK.append(RANKS["Ten"])
-
class Nine(Rank):
def __init__(self):
Rank.__init__(self, "9")
-RANKS["Nine"] = type(Nine())
-TYPES_OF_RANK.append(RANKS["Nine"])
-
class Eight(Rank):
def __init__(self):
Rank.__init__(self, "8")
-RANKS["Eight"] = type(Eight())
-TYPES_OF_RANK.append(RANKS["Eight"])
-
class Seven(Rank):
def __init__(self):
Rank.__init__(self, "7")
-RANKS["Seven"] = type(Seven())
-TYPES_OF_RANK.append(RANKS["Seven"])
-
class Six(Rank):
def __init__(self):
Rank.__init__(self, "6")
-RANKS["Six"] = type(Six())
-TYPES_OF_RANK.append(RANKS["Six"])
-
class Five(Rank):
def __init__(self):
Rank.__init__(self, "5")
-RANKS["Five"] = type(Five())
-TYPES_OF_RANK.append(RANKS["Five"])
-
class Four(Rank):
def __init__(self):
Rank.__init__(self, "4")
-RANKS["Four"] = type(Four())
-TYPES_OF_RANK.append(RANKS["Four"])
-
class Three(Rank):
def __init__(self):
Rank.__init__(self, "3")
-RANKS["Three"] = type(Three())
-TYPES_OF_RANK.append(RANKS["Three"])
-
class Two(Rank):
def __init__(self):
Rank.__init__(self, "2")
-RANKS["Two"] = type(Two())
-TYPES_OF_RANK.append(RANKS["Two"])
-
class Ace(Rank):
def __init__(self):
Rank.__init__(self, "A")
-RANKS["Ace"] = type(Ace())
-TYPES_OF_RANK.append(RANKS["Ace"])
+RANKS = {"King": King, "Queen": Queen, "Jack": Jack, "Ten": Ten, "Nine": Nine,
+ "Eight": Eight, "Seven": Seven, "Six": Six, "Five": Five, "Four": Four,
+ "Three": Three, "Two": Two, "Ace": Ace}
+TYPES_OF_RANK = [King, Queen, Jack, Ten, Nine, Eight, Seven, Six, Five, Four,
+Three, Two, Ace]
-SUITS = {}
-TYPES_OF_SUITS = []
-
class Suit():
def __init__(self, color):
self.color = color
def __eq__(self, right):
return type(self) == type(right)
def __str__(self):
return type(self).__name__
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self, "red")
-SUITS["Diamonds"] = type(Diamonds())
-TYPES_OF_SUITS.append(SUITS["Diamonds"])
-
-
class Clubs(Suit):
def __init__(self):
Suit.__init__(self, "black")
-SUITS["Clubs"] = type(Clubs())
-TYPES_OF_SUITS.append(SUITS["Clubs"])
-
class Hearts(Suit):
def __init__(self):
Suit.__init__(self, "red")
-SUITS["Hearts"] = type(Hearts())
-TYPES_OF_SUITS.append(SUITS["Hearts"])
-
class Spades(Suit):
def __init__(self):
Suit.__init__(self, "black")
+SUITS = {"Diamonds": Diamonds, "Clubs": Clubs, "Hearts": Hearts,
+ "Spades": Spades}
+TYPES_OF_SUITS = [Diamonds, Clubs, Hearts, Spades]
-SUITS["Spades"] = type(Spades())
-TYPES_OF_SUITS.append(SUITS["Spades"])
-
class Card():
def __init__(self, rank, suit):
object.__setattr__(self, "rank", rank())
object.__setattr__(self, "suit", suit())
def __setattr__(self, *args):
raise Exception("can't set atribute")
def __eq__(self, right):
return self.suit == right.suit and self.rank == right.rank
def __str__(self):
return '{0} of {1}'.format(self.rank, self.suit)
class CardCollection():
def __init__(self, collection=[]):
self.collection = [card for card in collection]
def draw(self, index):
card = Card(self.collection[index].rank, self.collection[index].suit)
del self.collection[index]
return card
def draw_from_top(self):
card = Card(self.collection[-1].rank.__class__,
self.collection[-1].suit.__class__)
del self.collection[-1]
return card
def draw_from_bottom(self):
card = Card(self.collection[0].rank, self.collection[0].suit)
del self.collection[0]
return card
def top_card(self):
return self.collection[-1]
def bottom_card(self):
return self.collection[0]
def index(self, card):
return self.collection.index(card)
def __getitem__(self, index):
return self.collection[index]
def add(self, card):
self.collection.append(card)
def __len__(self):
return len(self.collection)
def StandardDeck():
card_collection = []
for suit in TYPES_OF_SUITS:
for rank in TYPES_OF_RANK:
card_collection.append(Card(rank, suit))
return card_collection
def BeloteDeck():
card_collection = []
for suit in TYPES_OF_SUITS:
for rank in TYPES_OF_RANK:
if rank == RANKS["Six"]:
break
card_collection.append(Card(rank, suit))
+ card_collection.append(Card(TYPES_OF_RANK[-1], TYPES_OF_SUITS[-1]))
return card_collection
def SixtySixDeck():
card_collection = []
for suit in TYPES_OF_SUITS:
for rank in TYPES_OF_RANK:
if rank == RANKS["Eight"]:
break
card_collection.append(Card(rank, suit))
+ card_collection.append(Card(TYPES_OF_RANK[-1], TYPES_OF_SUITS[-1]))
return card_collection