Решение на Тесте карти от Аделина Рудова

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

Към профила на Аделина Рудова

Резултати

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

Код

class Rank:
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self, other):
return self.symbol == other.symbol
def __str__(self):
return type(self).__name__
class Two(Rank):
def __init__(self):
self.symbol = '2'
super(Two, self).__init__(self.symbol)
def __str__(self):
return super(Two, self).__str__()
class Three(Rank):
def __init__(self):
self.symbol = '3'
super(Three, self).__init__(self.symbol)
def __str__(self):
return super(Three, self).__str__()
class Four(Rank):
def __init__(self):
self.symbol = '4'
super(Four, self).__init__(self.symbol)
def __str__(self):
return super(Four, self).__str__()
class Five(Rank):
def __init__(self):
self.symbol = '5'
super(Five, self).__init__(self.symbol)
def __str__(self):
return super(Five, self).__str__()
class Six(Rank):
def __init__(self):
self.symbol = '6'
super(Six, self).__init__(self.symbol)
def __str__(self):
return super(Six, self).__str__()
class Seven(Rank):
def __init__(self):
self.symbol = '7'
super(Seven, self).__init__(self.symbol)
def __str__(self):
return super(Seven, self).__str__()
class Eight(Rank):
def __init__(self):
self.symbol = '8'
super(Eight, self).__init__(self.symbol)
def __str__(self):
return super(Eight, self).__str__()
class Nine(Rank):
def __init__(self):
self.symbol = '9'
super(Nine, self).__init__(self.symbol)
def __str__(self):
return super(Nine, self).__str__()
class Ten(Rank):
def __init__(self):
self.symbol = '10'
super(Ten, self).__init__(self.symbol)
def __str__(self):
return super(Ten, self).__str__()
class Jack(Rank):
def __init__(self):
self.symbol = 'J'
super(Jack, self).__init__(self.symbol)
def __str__(self):
return super(Jack, self).__str__()
class Queen(Rank):
def __init__(self):
self.symbol = 'Q'
super(Queen, self).__init__(self.symbol)
def __str__(self):
return super(Queen, self).__str__()
class King(Rank):
def __init__(self):
self.symbol = 'K'
super(King, self).__init__(self.symbol)
def __str__(self):
return super(King, self).__str__()
class Ace(Rank):
def __init__(self):
self.symbol = 'A'
super(Ace, self).__init__(self.symbol)
def __str__(self):
return super(Ace, self).__str__()
class Suit:
def __init__(self, color):
self.color = color
def __eq__(self, other):
return self.suit == other.suit
def __str__(self):
return type(self).__name__
class Diamonds(Suit):
def __init__(self):
self.suit = 'Diamonds'
class Hearts(Suit):
def __init__(self):
self.suit = 'Hearts'
class Spades(Suit):
def __init__(self):
self.suit = 'Spades'
class Clubs(Suit):
def __init__(self):
self.suit = 'Clubs'
class Card:
def __init__(self, rank, suit):
self.rank = rank()
self.suit = suit()
def __str__(self):
return "{0} of {1}".format(self.rank, self.suit)
def __eq__(self, other):
return str(self) == str(other)
class CardCollection:
def __init__(self, collection):
self.collection = list(collection)
def draw(self, index):
card = self.collection[index]
self.collection.remove(card)
return card
def draw_from_top(self):
return self.draw(len(self.collection) - 1)
def draw_from_bottom(self):
return self.draw(0)
def top_card(self):
return self.collection[len(self.collection) - 1]
def bottom_card(self):
return self.collection[0]
def add(self, card):
self.collection.append(card)
def index(self, card):
return self.collection.index(card)
def __getitem__(self, i):
return self.collection[i]
def __len__(self):
return len(self.collection)
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}
BELOTE_DECK = ['King', 'Jack', 'Queen', 'Ten', 'Ace', 'Eight', 'Seven', 'Nine']
SIXTY_SIX_CARDS = ['King', 'Jack', 'Queen', 'Ten', 'Ace', 'Nine']

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

EE.E.EEE........
======================================================================
ERROR: 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-1rbfw62/test.py", line 174, in test_belote_deck
    cards = [str(card) for card in solution.BeloteDeck()]
AttributeError: 'module' object has no attribute 'BeloteDeck'

======================================================================
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-1rbfw62/test.py", line 117, in test_deck_add
    deck = solution.CardCollection()
TypeError: __init__() missing 1 required positional argument: 'collection'

======================================================================
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-1rbfw62/test.py", line 154, in test_deck_index
    deck = solution.CardCollection()
TypeError: __init__() missing 1 required positional argument: 'collection'

======================================================================
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-1rbfw62/test.py", line 129, in test_deck_order
    deck = solution.CardCollection()
TypeError: __init__() missing 1 required positional argument: 'collection'

======================================================================
ERROR: 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-1rbfw62/test.py", line 178, in test_sixtysix_deck
    cards = [str(card) for card in solution.SixtySixDeck()]
AttributeError: 'module' object has no attribute 'SixtySixDeck'

======================================================================
ERROR: 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-1rbfw62/test.py", line 170, in test_standard_deck
    cards = [str(card) for card in solution.StandardDeck()]
AttributeError: 'module' object has no attribute 'StandardDeck'

----------------------------------------------------------------------
Ran 16 tests in 0.026s

FAILED (errors=6)

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

Аделина обнови решението на 26.03.2014 16:21 (преди около 10 години)

+class Rank:
+ def __init__(self, symbol):
+ self.symbol = symbol
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return type(self).__name__
+
+
+class Two(Rank):
+ def __init__(self):
+ self.symbol = '2'
+ super(Two, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Two, self).__str__()
+
+
+class Three(Rank):
+ def __init__(self):
+ self.symbol = '3'
+ super(Three, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Three, self).__str__()
+
+
+class Four(Rank):
+ def __init__(self):
+ self.symbol = '4'
+ super(Four, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Four, self).__str__()
+
+
+class Five(Rank):
+ def __init__(self):
+ self.symbol = '5'
+ super(Five, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Five, self).__str__()
+
+
+class Six(Rank):
+ def __init__(self):
+ self.symbol = '6'
+ super(Six, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Six, self).__str__()
+
+
+class Seven(Rank):
+ def __init__(self):
+ self.symbol = '7'
+ super(Seven, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Seven, self).__str__()
+
+
+class Eight(Rank):
+ def __init__(self):
+ self.symbol = '8'
+ super(Eight, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Eight, self).__str__()
+
+
+class Nine(Rank):
+ def __init__(self):
+ self.symbol = '9'
+ super(Nine, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Nine, self).__str__()
+
+
+class Ten(Rank):
+ def __init__(self):
+ self.symbol = '10'
+ super(Ten, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Ten, self).__str__()
+
+
+class Jack(Rank):
+ def __init__(self):
+ self.symbol = 'J'
+ super(Jack, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Jack, self).__str__()
+
+
+class Queen(Rank):
+ def __init__(self):
+ self.symbol = 'Q'
+ super(Queen, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Queen, self).__str__()
+
+
+class King(Rank):
+ def __init__(self):
+ self.symbol = 'K'
+ super(King, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(King, self).__str__()
+
+
+class Ace(Rank):
+ def __init__(self):
+ self.symbol = 'A'
+ super(Ace, self).__init__(self.symbol)
+
+ def __str__(self):
+ return super(Ace, self).__str__()
+
+
+class Suit:
+ def __init__(self, color):
+ self.color = color
+
+ def __eq__(self, other):
+ return self.suit == other.suit
+
+ def __str__(self):
+ return type(self).__name__
+
+
+class Diamonds(Suit):
+ def __init__(self):
+ self.suit = 'Diamonds'
+
+
+class Hearts(Suit):
+ def __init__(self):
+ self.suit = 'Hearts'
+
+
+class Spades(Suit):
+ def __init__(self):
+ self.suit = 'Spades'
+
+
+class Clubs(Suit):
+ def __init__(self):
+ self.suit = 'Clubs'
+
+
+class Card:
+ def __init__(self, rank, suit):
+ self.rank = rank()
+ self.suit = suit()
+
+ def __str__(self):
+ return "{0} of {1}".format(self.rank, self.suit)
+
+ def __eq__(self, other):
+ return (self.rank == other.rank and
+ self.suit == other.suit)
+
+
+class CardCollection:
+ def __init__(self, collection):
+ self.collection = list(collection)
+
+ def draw(self, index):
+ card = self.collection[index]
+ self.collection.remove(card)
+ return card
+
+ def draw_from_top(self):
+ return draw(self, len(self.collection) - 1)
+
+ def draw_from_bottom(self):
+ return draw(self, 0)
+
+ def top_card(self):
+ return self.collection[len(self.collection) - 1]
+
+ def bottom_card(self):
+ return self.collection[0]
+
+ def add(self, card):
+ self.collection.append(card)
+
+ def index(self, card):
+ return self.collection.index(card)
+
+ def __getitem__(self, i):
+ return self.collection[i]
+
+
+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}
+BELOTE_CARDS = ['King', 'Jack', 'Queen', 'Ten', 'Ace', 'Eight', 'Seven', 'Nine']
+SIXTY_SIX_CARDS = ['King', 'Jack', 'Queen', 'Ten', 'Ace', 'Nine']

Аделина обнови решението на 26.03.2014 16:37 (преди около 10 години)

class Rank:
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self, other):
return self.symbol == other.symbol
def __str__(self):
return type(self).__name__
class Two(Rank):
def __init__(self):
self.symbol = '2'
super(Two, self).__init__(self.symbol)
def __str__(self):
return super(Two, self).__str__()
class Three(Rank):
def __init__(self):
self.symbol = '3'
super(Three, self).__init__(self.symbol)
def __str__(self):
return super(Three, self).__str__()
class Four(Rank):
def __init__(self):
self.symbol = '4'
super(Four, self).__init__(self.symbol)
def __str__(self):
return super(Four, self).__str__()
class Five(Rank):
def __init__(self):
self.symbol = '5'
super(Five, self).__init__(self.symbol)
def __str__(self):
return super(Five, self).__str__()
class Six(Rank):
def __init__(self):
self.symbol = '6'
super(Six, self).__init__(self.symbol)
def __str__(self):
return super(Six, self).__str__()
class Seven(Rank):
def __init__(self):
self.symbol = '7'
super(Seven, self).__init__(self.symbol)
def __str__(self):
return super(Seven, self).__str__()
class Eight(Rank):
def __init__(self):
self.symbol = '8'
super(Eight, self).__init__(self.symbol)
def __str__(self):
return super(Eight, self).__str__()
class Nine(Rank):
def __init__(self):
self.symbol = '9'
super(Nine, self).__init__(self.symbol)
def __str__(self):
return super(Nine, self).__str__()
class Ten(Rank):
def __init__(self):
self.symbol = '10'
super(Ten, self).__init__(self.symbol)
def __str__(self):
return super(Ten, self).__str__()
class Jack(Rank):
def __init__(self):
self.symbol = 'J'
super(Jack, self).__init__(self.symbol)
def __str__(self):
return super(Jack, self).__str__()
class Queen(Rank):
def __init__(self):
self.symbol = 'Q'
super(Queen, self).__init__(self.symbol)
def __str__(self):
return super(Queen, self).__str__()
class King(Rank):
def __init__(self):
self.symbol = 'K'
super(King, self).__init__(self.symbol)
def __str__(self):
return super(King, self).__str__()
class Ace(Rank):
def __init__(self):
self.symbol = 'A'
super(Ace, self).__init__(self.symbol)
def __str__(self):
return super(Ace, self).__str__()
class Suit:
def __init__(self, color):
self.color = color
def __eq__(self, other):
return self.suit == other.suit
def __str__(self):
return type(self).__name__
class Diamonds(Suit):
def __init__(self):
self.suit = 'Diamonds'
class Hearts(Suit):
def __init__(self):
self.suit = 'Hearts'
class Spades(Suit):
def __init__(self):
self.suit = 'Spades'
class Clubs(Suit):
def __init__(self):
self.suit = 'Clubs'
class Card:
def __init__(self, rank, suit):
self.rank = rank()
self.suit = suit()
def __str__(self):
return "{0} of {1}".format(self.rank, self.suit)
def __eq__(self, other):
- return (self.rank == other.rank and
- self.suit == other.suit)
+ return str(self) == str(other)
class CardCollection:
def __init__(self, collection):
self.collection = list(collection)
def draw(self, index):
card = self.collection[index]
self.collection.remove(card)
return card
def draw_from_top(self):
- return draw(self, len(self.collection) - 1)
+ return self.draw(len(self.collection) - 1)
def draw_from_bottom(self):
- return draw(self, 0)
+ return self.draw(0)
def top_card(self):
return self.collection[len(self.collection) - 1]
def bottom_card(self):
return self.collection[0]
def add(self, card):
self.collection.append(card)
def index(self, card):
return self.collection.index(card)
def __getitem__(self, i):
return self.collection[i]
+ def __len__(self):
+ return len(self.collection)
+
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}
-BELOTE_CARDS = ['King', 'Jack', 'Queen', 'Ten', 'Ace', 'Eight', 'Seven', 'Nine']
+BELOTE_DECK = ['King', 'Jack', 'Queen', 'Ten', 'Ace', 'Eight', 'Seven', 'Nine']
SIXTY_SIX_CARDS = ['King', 'Jack', 'Queen', 'Ten', 'Ace', 'Nine']