Решение на Тесте карти от Людмила Савова

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

Към профила на Людмила Савова

Резултати

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

Код

class Rank:
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __str__(self):
return self.__class__.__name__
class Suit:
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __str__(self):
return self.__class__.__name__
RANKS = {'Two': type('Two', (Rank,), {'symbol': '2'}),
'Three': type('Three', (Rank,), {'symbol': '3'}),
'Four': type('Four', (Rank,), {'symbol': '4'}),
'Five': type('Five', (Rank,), {'symbol': '5'}),
'Six': type('Six', (Rank,), {'symbol': '6'}),
'Seven': type('Seven', (Rank,), {'symbol': '7'}),
'Eight': type('Eight', (Rank,), {'symbol': '8'}),
'Nine': type('Nine', (Rank,), {'symbol': '9'}),
'Ten': type('Ten', (Rank,), {'symbol': '10'}),
'Jack': type('Jack', (Rank,), {'symbol': 'J'}),
'Queen': type('Queen', (Rank,), {'symbol': 'Q'}),
'King': type('King', (Rank,), {'symbol': 'K'}),
'Ace': type('Ace', (Rank,), {'symbol': 'A'})}
SUITS = {'Hearts': type('Hearts', (Suit, ), {'color': 'red'}),
'Diamonds': type('Diamonds', (Suit, ), {'color': 'red'}),
'Spades': type('Spades', (Suit, ), {'color': 'black'}),
'Clubs': type('Clubs', (Suit, ), {'color': 'black'})}
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 self.rank.__name__ + " of " + self.suit.__name__
class CardCollection:
def __init__(self, collection=[]):
self.collection = collection
def __getitem__(self, index):
return self.collection[index]
def __setitem__(self, index, value):
self.collection[index] = value
def __len__(self):
return len(self.collection)
def draw(self, index):
return self.collection.pop(index)
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[-1]
def bottom_card(self):
return self.collection[0]
def add(self, card):
self.collection.append(card)
def index(self, card):
first_found = next(obj for obj in self.collection if obj == card)
return self.collection.index(first_found)
def StandardDeck():
standard_deck = CardCollection()
for card_ranks in RANKS.keys():
for card_suits in SUITS.keys():
standard_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
return standard_deck.collection
def BeloteDeck():
belot_deck = CardCollection()
for card_ranks in RANKS.keys():
if RANKS[card_ranks].symbol not in ['2', '3', '4', '5', '6']:
for card_suits in SUITS.keys():
belot_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
return belot_deck.collection
def SixtySixDeck():
six_deck = CardCollection()
for card_ranks in RANKS.keys():
if RANKS[card_ranks].symbol not in ['2', '3', '4', '5', '6', '7', '8']:
for card_suits in SUITS.keys():
six_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
return six_deck.collection

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

FE.E.EFFF.FF.FF.
======================================================================
ERROR: test_deck_add (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-15t5azv/test.py", line 121, in test_deck_add
    self.assertEqual(deck[0], card1)
  File "/opt/python3.3/lib/python3.3/unittest/case.py", line 642, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/opt/python3.3/lib/python3.3/unittest/case.py", line 632, in _baseAssertEqual
    if not first == second:
  File "/tmp/d20140407-19315-15t5azv/solution.py", line 43, in __eq__
    return self.rank == other.rank and self.suit == other.suit
AttributeError: 'str' object has no attribute 'rank'

======================================================================
ERROR: test_deck_index (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-15t5azv/test.py", line 160, in test_deck_index
    self.assertEqual(0, deck.index(card1))
  File "/tmp/d20140407-19315-15t5azv/solution.py", line 81, in index
    first_found = next(obj for obj in self.collection if obj == card)
  File "/tmp/d20140407-19315-15t5azv/solution.py", line 81, in <genexpr>
    first_found = next(obj for obj in self.collection if obj == card)
  File "/tmp/d20140407-19315-15t5azv/solution.py", line 43, in __eq__
    return self.rank == other.rank and self.suit == other.suit
AttributeError: 'str' object has no attribute 'rank'

======================================================================
ERROR: test_deck_order (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-15t5azv/test.py", line 134, in test_deck_order
    self.assertEqual(deck.bottom_card(), card1)
  File "/opt/python3.3/lib/python3.3/unittest/case.py", line 642, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/opt/python3.3/lib/python3.3/unittest/case.py", line 632, in _baseAssertEqual
    if not first == second:
  File "/tmp/d20140407-19315-15t5azv/solution.py", line 43, in __eq__
    return self.rank == other.rank and self.suit == other.suit
AttributeError: 'str' object has no attribute 'rank'

======================================================================
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-15t5azv/test.py", line 175, in test_belote_deck
    self.assertEqual(BELOTE_DECK, cards)
AssertionError: Lists differ: ['King of Diamonds', 'Queen of... != ['King of Diamonds', 'King of ...

First differing element 1:
Queen of Diamonds
King of Spades

Diff is 1277 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-15t5azv/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', 'King of ...

First differing element 1:
Queen of Diamonds
King of Spades

Second list contains 38 additional elements.
First extra element 24:
Nine of Diamonds

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

======================================================================
FAIL: test_standard_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-15t5azv/test.py", line 171, in test_standard_deck
    self.assertEqual(STANDARD_DECK, cards)
AssertionError: Lists differ: ['King of Diamonds', 'Queen of... != ['King of Diamonds', 'King of ...

First differing element 1:
Queen of Diamonds
King of Spades

Second list contains 62 additional elements.
First extra element 52:
Ten of Hearts

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

======================================================================
FAIL: test_all_card_instances (test.CardTest)
----------------------------------------------------------------------
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-15t5azv/test.py", line 67, in test_all_card_instances
    self.assertIsInstance(card.rank, rank)
AssertionError: <class 'solution.Four'> is not an instance of <class 'solution.Four'>

======================================================================
FAIL: test_all_suits_ranks_equal (test.CardTest)
----------------------------------------------------------------------
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-15t5azv/test.py", line 92, in test_all_suits_ranks_equal
    self.assertEqual(card.rank, rank())
AssertionError: <class 'solution.Four'> != <solution.Four object at 0xb6d51f6c>

======================================================================
FAIL: test_all_to_string (test.CardTest)
----------------------------------------------------------------------
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-15t5azv/test.py", line 104, in test_all_to_string
    + " of " + str(card.suit))
AssertionError: 'Four of Diamonds' != "<class 'solution.Four'> of <class 'solution.Diamonds'>"
- Four of Diamonds
+ <class 'solution.Four'> of <class 'solution.Diamonds'>


======================================================================
FAIL: test_card_instance (test.CardTest)
----------------------------------------------------------------------
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-15t5azv/test.py", line 60, in test_card_instance
    self.assertIsInstance(aos.rank, solution.RANKS["Ace"])
AssertionError: <class 'solution.Ace'> is not an instance of <class 'solution.Ace'>

======================================================================
FAIL: test_suit_rank_equals (test.CardTest)
----------------------------------------------------------------------
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-15t5azv/test.py", line 85, in test_suit_rank_equals
    self.assertEqual(aos.rank, solution.RANKS["Ace"]())
AssertionError: <class 'solution.Ace'> != <solution.Ace object at 0xb6d599ac>

----------------------------------------------------------------------
Ran 16 tests in 0.050s

FAILED (failures=8, errors=3)

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

Людмила обнови решението на 22.03.2014 21:56 (преди около 10 години)

+class Rank:
+ def __init__(self, symbol=''):
+ self.symbol = symbol
+
+ def __eq__(self, other):
+ if self.__dict__ == other.__dict__:
+ return True
+ else:
+ return False
+
+ def __str__(self):
+ return self.__class__.__name__
+
+
+class Suite:
+ def __init__(self, color=''):
+ self.color = color
+
+ def __eq__(self, other):
+ if self.__dict__ == other.__dict__:
+ return True
+ else:
+ return False
+
+ def __str__(self):
+ return self.__class__.__name__
+
+
+class Card:
+
+ def __init__(self, rank='', suite=''):
+ self.rank = rank
+ self.suite = suite
+
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return self.__dict__ == other.__dict__
+
+ def __str__(self):
+ return self.rank.__name__ + " of " + self.suite.__name__
+
+
+class CardCollection:
+ def __init__(self, collection=[]):
+ self.collection = collection
+
+ def __getitem__(self, index):
+ return self.collection[index]
+
+ def __setitem__(self, index, value):
+ self.collection[index] = value
+
+ def __len__(self):
+ return len(self.collection)
+
+ def draw(self, index):
+ return self.collection.pop(index)
+
+ 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[-1]
+
+ def bottom_card(self):
+ return self.collection[0]
+
+ def add(self, card):
+ self.collection.append(card)
+
+ def index(self, card):
+ first_found = next(obj for obj in self.collection if obj == card)
+ return self.collection.index(first_found)
+
+
+RANKS = {'Two': type('Two', (Rank,), {'symbol': '2'}),
+ 'Three': type('Three', (Rank,), {'symbol': '3'}),
+ 'Four': type('Four', (Rank,), {'symbol': '4'}),
+ 'Five': type('Five', (Rank,), {'symbol': '5'}),
+ 'Six': type('Six', (Rank,), {'symbol': '6'}),
+ 'Seven': type('Seven', (Rank,), {'symbol': '7'}),
+ 'Eight': type('Eight', (Rank,), {'symbol': '8'}),
+ 'Nine': type('Nine', (Rank,), {'symbol': '9'}),
+ 'Ten': type('Ten', (Rank,), {'symbol': '10'}),
+ 'Jack': type('Jack', (Rank,), {'symbol': 'J'}),
+ 'Queen': type('Queen', (Rank,), {'symbol': 'Q'}),
+ 'King': type('King', (Rank,), {'symbol': 'K'}),
+ 'Ace': type('Ace', (Rank,), {'symbol': 'A'})}
+
+SUITS = {'Hearts': type('Hearts', (Suite, ), {'color': 'red'}),
+ 'Diamonds': type('Diamonds', (Suite, ), {'color': 'red'}),
+ 'Spades': type('Spades', (Suite, ), {'color': 'black'}),
+ 'Clubs': type('Clubs', (Suite, ), {'color': 'black'})}
+
+
+def StandardDeck():
+ standard_deck = CardCollection()
+ for card_ranks in RANKS.keys():
+ for card_suits in SUITS.keys():
+ standard_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
+ return standard_deck.collection
+
+
+def BeloteDeck():
+ belot_deck = CardCollection()
+ for card_ranks in RANKS.keys():
+ if RANKS[card_ranks].symbol not in ['2', '3', '4', '5', '6']:
+ for card_suits in SUITS.keys():
+ belot_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
+ return belot_deck.collection
+
+
+def SixtySixDeck():
+ six_deck = CardCollection()
+ for card_ranks in RANKS.keys():
+ if RANKS[card_ranks].symbol not in ['2', '3', '4', '5', '6', '7', '8']:
+ for card_suits in SUITS.keys():
+ six_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
+ return six_deck.collection

Отлично решение, но имаш правописна грешка което го чупи цялото! Suit а не Suite. Suite означава друго.

Някои подробности:

Имплементацията ти на __eq__ ще проработи но в Питон сме фенове на Патешкото Типизиране и е достатъчно да проверяваш само дали self.rank == other.rank and self.suit == other.suit. Проверката на типове класове е за езици като C++ и Java.

Освен това не виждам защо са ти нужни конструктори на Rank и Suit.

Благодаря за коментара Людмил, но имам два фейлващи теста и те са следните: assertIsInstance(aos.rank, RANKS["Ace"]) и assertEqual(aos.rank, RANKS"Ace"). Доколкото разбирам rank на карта трябва да е клас, а не инстанция, тогава защо го сравняваме с инстанция в тестовете? Мисля, че тези два теста, вотрите им аргументи трябва да са разменени или съм изпаднала в някаква заблуда :D

Людмила обнови решението на 24.03.2014 12:06 (преди около 10 години)

class Rank:
- def __init__(self, symbol=''):
- self.symbol = symbol
-
def __eq__(self, other):
if self.__dict__ == other.__dict__:
return True
else:
return False
def __str__(self):
return self.__class__.__name__
-class Suite:
- def __init__(self, color=''):
- self.color = color
-
+class Suit:
def __eq__(self, other):
if self.__dict__ == other.__dict__:
return True
else:
return False
def __str__(self):
return self.__class__.__name__
class Card:
- def __init__(self, rank='', suite=''):
+ def __init__(self, rank='', suit=''):
self.rank = rank
- self.suite = suite
+ self.suit = suit
def __eq__(self, other):
- if isinstance(other, self.__class__):
- return self.__dict__ == other.__dict__
+ if self.rank == other.rank and self.suit == other.suit:
+ return True
+ else:
+ return False
def __str__(self):
- return self.rank.__name__ + " of " + self.suite.__name__
+ return self.rank.__name__ + " of " + self.suit.__name__
class CardCollection:
def __init__(self, collection=[]):
self.collection = collection
def __getitem__(self, index):
return self.collection[index]
def __setitem__(self, index, value):
self.collection[index] = value
def __len__(self):
return len(self.collection)
def draw(self, index):
return self.collection.pop(index)
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[-1]
def bottom_card(self):
return self.collection[0]
def add(self, card):
self.collection.append(card)
def index(self, card):
first_found = next(obj for obj in self.collection if obj == card)
return self.collection.index(first_found)
RANKS = {'Two': type('Two', (Rank,), {'symbol': '2'}),
'Three': type('Three', (Rank,), {'symbol': '3'}),
'Four': type('Four', (Rank,), {'symbol': '4'}),
'Five': type('Five', (Rank,), {'symbol': '5'}),
'Six': type('Six', (Rank,), {'symbol': '6'}),
'Seven': type('Seven', (Rank,), {'symbol': '7'}),
'Eight': type('Eight', (Rank,), {'symbol': '8'}),
'Nine': type('Nine', (Rank,), {'symbol': '9'}),
'Ten': type('Ten', (Rank,), {'symbol': '10'}),
'Jack': type('Jack', (Rank,), {'symbol': 'J'}),
'Queen': type('Queen', (Rank,), {'symbol': 'Q'}),
'King': type('King', (Rank,), {'symbol': 'K'}),
'Ace': type('Ace', (Rank,), {'symbol': 'A'})}
-SUITS = {'Hearts': type('Hearts', (Suite, ), {'color': 'red'}),
- 'Diamonds': type('Diamonds', (Suite, ), {'color': 'red'}),
- 'Spades': type('Spades', (Suite, ), {'color': 'black'}),
- 'Clubs': type('Clubs', (Suite, ), {'color': 'black'})}
+SUITS = {'Hearts': type('Hearts', (Suit, ), {'color': 'red'}),
+ 'Diamonds': type('Diamonds', (Suit, ), {'color': 'red'}),
+ 'Spades': type('Spades', (Suit, ), {'color': 'black'}),
+ 'Clubs': type('Clubs', (Suit, ), {'color': 'black'})}
def StandardDeck():
standard_deck = CardCollection()
for card_ranks in RANKS.keys():
for card_suits in SUITS.keys():
standard_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
return standard_deck.collection
def BeloteDeck():
belot_deck = CardCollection()
for card_ranks in RANKS.keys():
if RANKS[card_ranks].symbol not in ['2', '3', '4', '5', '6']:
for card_suits in SUITS.keys():
belot_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
return belot_deck.collection
def SixtySixDeck():
six_deck = CardCollection()
for card_ranks in RANKS.keys():
if RANKS[card_ranks].symbol not in ['2', '3', '4', '5', '6', '7', '8']:
for card_suits in SUITS.keys():
six_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
return six_deck.collection
+
  • в CardCollection не се очакват низове а инстанции на картите
    • подредбата в тях е важна и зададена по условие.
  • може би е малко неясно, но в __init__ на картите се подават класовете на ранговете им, но в инстанциите(на картите) се очаква да има инстанции на ранговете

  • Това се прави на един ред:

    if something:
        return True
    else:
        return False
    

    ето така:

    return something
    
  • в Ranks и Suits имаш адски много повтарящ се код. Използвай подходяща конструкция(dict comprehension, например) и си изнеси различаващите се елементи в подходящи структури.

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

class Rank:
def __eq__(self, other):
- if self.__dict__ == other.__dict__:
- return True
- else:
- return False
+ return self.__dict__ == other.__dict__
def __str__(self):
return self.__class__.__name__
class Suit:
def __eq__(self, other):
- if self.__dict__ == other.__dict__:
- return True
- else:
- return False
+ return self.__dict__ == other.__dict__
def __str__(self):
return self.__class__.__name__
+RANKS = {'Two': type('Two', (Rank,), {'symbol': '2'}),
+ 'Three': type('Three', (Rank,), {'symbol': '3'}),
+ 'Four': type('Four', (Rank,), {'symbol': '4'}),
+ 'Five': type('Five', (Rank,), {'symbol': '5'}),
+ 'Six': type('Six', (Rank,), {'symbol': '6'}),
+ 'Seven': type('Seven', (Rank,), {'symbol': '7'}),
+ 'Eight': type('Eight', (Rank,), {'symbol': '8'}),
+ 'Nine': type('Nine', (Rank,), {'symbol': '9'}),
+ 'Ten': type('Ten', (Rank,), {'symbol': '10'}),
+ 'Jack': type('Jack', (Rank,), {'symbol': 'J'}),
+ 'Queen': type('Queen', (Rank,), {'symbol': 'Q'}),
+ 'King': type('King', (Rank,), {'symbol': 'K'}),
+ 'Ace': type('Ace', (Rank,), {'symbol': 'A'})}
-class Card:
+SUITS = {'Hearts': type('Hearts', (Suit, ), {'color': 'red'}),
+ 'Diamonds': type('Diamonds', (Suit, ), {'color': 'red'}),
+ 'Spades': type('Spades', (Suit, ), {'color': 'black'}),
+ 'Clubs': type('Clubs', (Suit, ), {'color': 'black'})}
- def __init__(self, rank='', suit=''):
+
+class Card(object):
+
+ def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
def __eq__(self, other):
- if self.rank == other.rank and self.suit == other.suit:
- return True
- else:
- return False
+ return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return self.rank.__name__ + " of " + self.suit.__name__
class CardCollection:
def __init__(self, collection=[]):
self.collection = collection
def __getitem__(self, index):
return self.collection[index]
def __setitem__(self, index, value):
self.collection[index] = value
def __len__(self):
return len(self.collection)
def draw(self, index):
return self.collection.pop(index)
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[-1]
def bottom_card(self):
return self.collection[0]
def add(self, card):
self.collection.append(card)
def index(self, card):
first_found = next(obj for obj in self.collection if obj == card)
return self.collection.index(first_found)
-RANKS = {'Two': type('Two', (Rank,), {'symbol': '2'}),
- 'Three': type('Three', (Rank,), {'symbol': '3'}),
- 'Four': type('Four', (Rank,), {'symbol': '4'}),
- 'Five': type('Five', (Rank,), {'symbol': '5'}),
- 'Six': type('Six', (Rank,), {'symbol': '6'}),
- 'Seven': type('Seven', (Rank,), {'symbol': '7'}),
- 'Eight': type('Eight', (Rank,), {'symbol': '8'}),
- 'Nine': type('Nine', (Rank,), {'symbol': '9'}),
- 'Ten': type('Ten', (Rank,), {'symbol': '10'}),
- 'Jack': type('Jack', (Rank,), {'symbol': 'J'}),
- 'Queen': type('Queen', (Rank,), {'symbol': 'Q'}),
- 'King': type('King', (Rank,), {'symbol': 'K'}),
- 'Ace': type('Ace', (Rank,), {'symbol': 'A'})}
-
-SUITS = {'Hearts': type('Hearts', (Suit, ), {'color': 'red'}),
- 'Diamonds': type('Diamonds', (Suit, ), {'color': 'red'}),
- 'Spades': type('Spades', (Suit, ), {'color': 'black'}),
- 'Clubs': type('Clubs', (Suit, ), {'color': 'black'})}
-
-
def StandardDeck():
standard_deck = CardCollection()
for card_ranks in RANKS.keys():
for card_suits in SUITS.keys():
standard_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
return standard_deck.collection
def BeloteDeck():
belot_deck = CardCollection()
for card_ranks in RANKS.keys():
if RANKS[card_ranks].symbol not in ['2', '3', '4', '5', '6']:
for card_suits in SUITS.keys():
belot_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
return belot_deck.collection
def SixtySixDeck():
six_deck = CardCollection()
for card_ranks in RANKS.keys():
if RANKS[card_ranks].symbol not in ['2', '3', '4', '5', '6', '7', '8']:
for card_suits in SUITS.keys():
six_deck.add(str(Card(RANKS[card_ranks], SUITS[card_suits])))
return six_deck.collection
-