Решение на Четвърта задача от Боян Дончев

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

Към профила на Боян Дончев

Резултати

  • 1 точка от тестове
  • 0 бонус точки
  • 1 точка общо
  • 9 успешни тест(а)
  • 48 неуспешни тест(а)

Код

RANKS = %w(2 3 4 5 6 7 8 9 10 :jack :queen :king :ace)
SUITS = %w(:spades :hearts :diamonds :clubs)
class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def to_s
@rank.to_s.capitalize + " of " + @suit[0..@suit.length].capitalize
end
end
class Deck
attr_accessor :cards
def initialize
@cards = []
SUITS.each do |suit|
RANKS.reverse.each do |rank|
@cards << Card.new(rank, suit)
end
end
end
def shuffle
cards.shuffle!
end
def sort
initialize
end
def size
@cards.length
end
def draw_top_card
@cards.shift
end
def draw_bottom_card
@cards.pop
end
def top_card
@cards.first
end
def bottom_card
@cards.last
end
def to_s
@cards.each do |card|
puts card.to_s
end
end
def deal
case
when WarDeck
w = WarDeck.new
w.draw
end
end
end
class WarDeck < Deck
include Enumerable
attr_accessor :cards
def initialize
super
@cards.shuffle!
end
def deal
initialize
draw = Hand.new
26.times do draw.hand << @cards.pop end
draw
end
def size
@cards.length
end
class Hand
attr_accessor :hand
def initialize
@hand = []
end
def size
@hand.length
end
def allow_face_up?
@hand.length <= 3
end
def play_card
@hand.shift
end
end
end
class SixtySixDeck < Deck
include Enumerable
attr_accessor :cards
def initialize
@cards, @hand = [], []
SUITS.each do |suit|
RANKS[6..RANKS.length].each do |rank|
@cards << Card.new(rank, suit)
end
end
end
def deal
initialize
draw = Hand.new
6.times do draw.hand << @cards.pop end
draw
end
def size
@hand.length
end
class Hand
attr_accessor :hand
def initialize
@hand = []
end
def forty?(trump_suit)
(@hand.include? Card.new(:king, trump_suit)) &&
(@hand.include? Card.new(:queen, trump_suit))
end
def twenty?(trump_suit)
end
def size
@hand.length
end
end
end
class BeloteDeck < Deck
end

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

..FFFFFFFF.FF...FFFFFFF.FFFFFFFFFFFFFFFFFFFFFFFFFF.FF.FFF

Failures:

  1) Card #== compares two cards by their rank and suit
     Failure/Error: expect(Card.new(4, :spades)).to eq Card.new(4, :spades)
       
       expected: #<Card:0x007f2b43f55210 @rank=4, @suit=:spades>
            got: #<Card:0x007f2b43f552b0 @rank=4, @suit=:spades>
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007f2b43f55210 @rank=4, @suit=:spades>
       +#<Card:0x007f2b43f552b0 @rank=4, @suit=:spades>
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:131:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) WarDeck behaves like a deck implements Enumerable
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:140
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:63:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:10:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) WarDeck behaves like a deck fills the deck if no initialize parameters are given
     Failure/Error: expect(deck.to_a).to match_array all_available_cards
     NoMethodError:
       undefined method `each' for #<WarDeck:0x007f2b43f2da08>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:140
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:18:in `to_a'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:18:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) WarDeck behaves like a deck #size returns the size of the deck
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:140
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:63:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:23:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) WarDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:140
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:63:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:29:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  6) WarDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:140
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:63:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:36:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  7) WarDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:140
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:63:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:43:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  8) WarDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:140
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:63:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:50:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  9) WarDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:140
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:63:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:68:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  10) WarDeck #sort sorts the cards in the defined order
     Failure/Error: deck = WarDeck.new(cards)
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:63:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:153:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:153:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  11) BeloteDeck behaves like a deck implements Enumerable
     Failure/Error: expect(deck_class).to include(Enumerable)
       expected BeloteDeck to include Enumerable
       Diff:
       @@ -1,2 +1,2 @@
       -[Enumerable]
       +BeloteDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:191
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:9:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  12) BeloteDeck behaves like a deck fills the deck if no initialize parameters are given
     Failure/Error: expect(deck.to_a).to match_array all_available_cards
     NoMethodError:
       undefined method `to_a' for #<BeloteDeck:0x007f2b44d8ad30>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:191
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:18:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  13) BeloteDeck behaves like a deck #size returns the size of the deck
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:191
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:23:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  14) BeloteDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:191
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:29:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  15) BeloteDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:191
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:36:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  16) BeloteDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:191
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:43:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  17) BeloteDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:191
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:50:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  18) BeloteDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:191
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:68:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  19) BeloteDeck #sort sorts the cards in the defined order
     Failure/Error: deck = BeloteDeck.new(cards)
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:204:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:204:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  20) BeloteDeck hand #deal deals 8 cards
     Failure/Error: hand = BeloteDeck.new.deal
     NoMethodError:
       undefined method `draw' for #<WarDeck:0x007f2b44cea718>
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:55:in `deal'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:213:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  21) BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:221:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:221:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  22) BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:240:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:240:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  23) BeloteDeck hand #belote? returns false when there is no king and queen of the same suit
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:255:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:255:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  24) BeloteDeck hand #tierce? with tierce returns true for cards with names
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:273:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:273:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  25) BeloteDeck hand #tierce? with tierce returns true for cards with numbers
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:288:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:288:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  26) BeloteDeck hand #tierce? without tierce does not confuse cards with different suits
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:305:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:305:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  27) BeloteDeck hand #quarte? detects four cards with increasing ranks
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:323:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:323:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  28) BeloteDeck hand #quarte? does not return true if there is no quarte
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:338:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:338:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  29) BeloteDeck hand #quint? detects five cards with increasing ranks
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:355:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:355:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  30) BeloteDeck hand #quint? does not return true if there is no quint
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:370:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:370:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  31) BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:386
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:75:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:75:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  32) BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns false when there is no carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:386
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:90:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:90:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  33) BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:390
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:75:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:75:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  34) BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns false when there is no carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:390
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:90:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:90:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  35) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:394
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:75:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:75:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  36) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns false when there is no carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:394
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:16:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:90:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:90:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  37) SixtySixDeck behaves like a deck implements Enumerable
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:400
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:10:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  38) SixtySixDeck behaves like a deck fills the deck if no initialize parameters are given
     Failure/Error: expect(deck.to_a).to match_array all_available_cards
     NoMethodError:
       undefined method `each' for #<SixtySixDeck:0x007f2b44ba3670>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:400
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:18:in `to_a'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:18:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  39) SixtySixDeck behaves like a deck #size returns the size of the deck
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:400
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:23:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  40) SixtySixDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:400
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:29:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  41) SixtySixDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:400
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:36:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  42) SixtySixDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:400
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:43:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  43) SixtySixDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:400
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:50:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  44) SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1qo8bw2/spec.rb:400
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:68:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  45) SixtySixDeck #sort sorts the cards in the defined order
     Failure/Error: deck = SixtySixDeck.new(cards)
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:413:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:413:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  46) SixtySixDeck hand #twenty? returns true for king and queen not of the trump suit
     Failure/Error: hand = SixtySixDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:430:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:430:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  47) SixtySixDeck hand #twenty? returns false for king and queen of the trump suit
     Failure/Error: hand = SixtySixDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:443:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:443:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  48) SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit
     Failure/Error: hand = SixtySixDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-1qo8bw2/solution.rb:98:in `initialize'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:456:in `new'
     # /tmp/d20151112-27349-1qo8bw2/spec.rb:456:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.04011 seconds
57 examples, 48 failures

Failed examples:

rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:130 # Card #== compares two cards by their rank and suit
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:8 # WarDeck behaves like a deck implements Enumerable
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:14 # WarDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:22 # WarDeck behaves like a deck #size returns the size of the deck
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:28 # WarDeck behaves like a deck #draw_top_card pops the top-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:35 # WarDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:42 # WarDeck behaves like a deck #top peeks at the top-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:49 # WarDeck behaves like a deck #bottom peeks at the bottom-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:67 # WarDeck behaves like a deck #to_s returns the names of the cards, each on its own line
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:145 # WarDeck #sort sorts the cards in the defined order
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:8 # BeloteDeck behaves like a deck implements Enumerable
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:14 # BeloteDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:22 # BeloteDeck behaves like a deck #size returns the size of the deck
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:28 # BeloteDeck behaves like a deck #draw_top_card pops the top-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:35 # BeloteDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:42 # BeloteDeck behaves like a deck #top peeks at the top-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:49 # BeloteDeck behaves like a deck #bottom peeks at the bottom-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:67 # BeloteDeck behaves like a deck #to_s returns the names of the cards, each on its own line
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:196 # BeloteDeck #sort sorts the cards in the defined order
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:212 # BeloteDeck hand #deal deals 8 cards
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:220 # BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:239 # BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:254 # BeloteDeck hand #belote? returns false when there is no king and queen of the same suit
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:272 # BeloteDeck hand #tierce? with tierce returns true for cards with names
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:287 # BeloteDeck hand #tierce? with tierce returns true for cards with numbers
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:304 # BeloteDeck hand #tierce? without tierce does not confuse cards with different suits
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:322 # BeloteDeck hand #quarte? detects four cards with increasing ranks
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:337 # BeloteDeck hand #quarte? does not return true if there is no quarte
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:354 # BeloteDeck hand #quint? detects five cards with increasing ranks
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:369 # BeloteDeck hand #quint? does not return true if there is no quint
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:74 # BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:89 # BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns false when there is no carre
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:74 # BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:89 # BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns false when there is no carre
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:74 # BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:89 # BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns false when there is no carre
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:8 # SixtySixDeck behaves like a deck implements Enumerable
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:14 # SixtySixDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:22 # SixtySixDeck behaves like a deck #size returns the size of the deck
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:28 # SixtySixDeck behaves like a deck #draw_top_card pops the top-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:35 # SixtySixDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:42 # SixtySixDeck behaves like a deck #top peeks at the top-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:49 # SixtySixDeck behaves like a deck #bottom peeks at the bottom-most card
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:67 # SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:405 # SixtySixDeck #sort sorts the cards in the defined order
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:429 # SixtySixDeck hand #twenty? returns true for king and queen not of the trump suit
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:442 # SixtySixDeck hand #twenty? returns false for king and queen of the trump suit
rspec /tmp/d20151112-27349-1qo8bw2/spec.rb:455 # SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit

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

Боян обнови решението на 10.11.2015 23:28 (преди около 9 години)

+RANKS = %w(2 3 4 5 6 7 8 9 10 :jack :queen :king :ace)
+SUITS = %w(:spades :hearts :diamonds :clubs)
+class Card
+ attr_accessor :rank, :suit
+ def initialize(rank, suit)
+ @rank = rank
+ @suit = suit
+ end
+ def rank
+ @rank
+ end
+ def suit
+ @suit
+ end
+ def to_s
+ @rank.to_s + " of " + @suit.to_s
+ end
+end

Боян обнови решението на 10.11.2015 23:28 (преди около 9 години)

RANKS = %w(2 3 4 5 6 7 8 9 10 :jack :queen :king :ace)
SUITS = %w(:spades :hearts :diamonds :clubs)
class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def rank
@rank
end
def suit
@suit
end
def to_s
@rank.to_s + " of " + @suit.to_s
end
end
+
+class Deck
+ attr_accessor :cards
+ def initialize
+ @cards = []
+ SUITS.each do |suit|
+ RANKS.reverse.each do |rank|
+ @cards << Card.new(rank, suit)
+ end
+ end
+ end
+ def shuffle
+ cards.shuffle!
+ end
+ def sort
+ initialize
+ end
+ def size
+ @cards.length
+ end
+ def draw_top_card
+ @cards.shift
+ end
+ def draw_bottom_card
+ @cards.pop
+ end
+ def top_card
+ @cards.first
+ end
+ def bottom_card
+ @cards.last
+ end
+ def to_s
+ @cards.each do |card|
+ puts card.to_s
+ end
+ end
+end

Боян обнови решението на 11.11.2015 01:50 (преди около 9 години)

RANKS = %w(2 3 4 5 6 7 8 9 10 :jack :queen :king :ace)
SUITS = %w(:spades :hearts :diamonds :clubs)
class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
- @rank = rank
- @suit = suit
+ @rank = rank
+ @suit = suit
end
def rank
- @rank
+ @rank
end
def suit
- @suit
+ @suit
end
def to_s
- @rank.to_s + " of " + @suit.to_s
+ if @rank.length > 2
+ @rank[1..@rank.length].capitalize +
+ " of "
+ + @suit[1..@suit.length].capitalize
+ else @rank + " of " + @suit[1..@suit.length].capitalize
+ end
end
end
class Deck
attr_accessor :cards
def initialize
@cards = []
SUITS.each do |suit|
RANKS.reverse.each do |rank|
@cards << Card.new(rank, suit)
end
end
end
def shuffle
cards.shuffle!
end
def sort
initialize
end
def size
@cards.length
end
def draw_top_card
@cards.shift
end
def draw_bottom_card
@cards.pop
end
def top_card
@cards.first
end
def bottom_card
@cards.last
end
def to_s
- @cards.each do |card|
- puts card.to_s
+ @cards.each do |card|
+ puts card.to_s
+ end
+ end
+
+ def draw
+ case
+ when WarDeck
+ w = WarDeck.new
+ w.draw
end
end
-end
+end
+
+class WarDeck < Deck
+ include Enumerable
+ attr_accessor :hand, :cards
+ def initialize
+ super
+ @hand = []
+ @cards.shuffle!
+ 26.times do @hand << @cards.pop end
+ end
+ def deal
+ initialize
+ @hand
+ end
+ def play_card
+ @hand.shift
+ end
+ def allow_face_up?
+ @hand.length <= 3
+ end
+ def size
+ @hand.length
+ end
+end
+
+class SixtySixDeck < Deck
+
+ ranks = %w(9 10 :jack :queen :king :ace)
+ suits = %w(:spades :hearts :diamonds :clubs)
+ attr_accessor :hand, :cards
+ def initialize
+ @cards = []
+ suits.each do |suit|
+ ranks.each do |rank|
+ @cards << Card.new(rank, suit)
+ end
+ end
+ 6.times do @hand << @cards.pop end
+ end
+ def deal
+ initialize
+ @hand
+ end
+ def size
+ 24
+ end
+ def forty?(trump_suit)
+ (@hand.include? Card.new(:king, trump_suit)) &&
+ (@hand.include? Card.new(:queen, trump_suit))
+ end
+ def twenty?(trump_suit)
+
+ end
+end

Боян обнови решението на 11.11.2015 02:03 (преди около 9 години)

RANKS = %w(2 3 4 5 6 7 8 9 10 :jack :queen :king :ace)
SUITS = %w(:spades :hearts :diamonds :clubs)
class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def rank
@rank
end
def suit
@suit
end
def to_s
if @rank.length > 2
@rank[1..@rank.length].capitalize +
" of "
+ @suit[1..@suit.length].capitalize
else @rank + " of " + @suit[1..@suit.length].capitalize
end
end
end
class Deck
attr_accessor :cards
def initialize
@cards = []
SUITS.each do |suit|
RANKS.reverse.each do |rank|
@cards << Card.new(rank, suit)
end
end
end
def shuffle
cards.shuffle!
end
def sort
initialize
end
def size
@cards.length
end
def draw_top_card
@cards.shift
end
def draw_bottom_card
@cards.pop
end
def top_card
@cards.first
end
def bottom_card
@cards.last
end
def to_s
@cards.each do |card|
puts card.to_s
end
end
def draw
case
- when WarDeck
+ when WarDeck
w = WarDeck.new
w.draw
end
end
end
class WarDeck < Deck
include Enumerable
attr_accessor :hand, :cards
def initialize
super
@hand = []
@cards.shuffle!
26.times do @hand << @cards.pop end
end
def deal
initialize
@hand
end
def play_card
@hand.shift
end
def allow_face_up?
@hand.length <= 3
end
def size
@hand.length
end
end
class SixtySixDeck < Deck
-
- ranks = %w(9 10 :jack :queen :king :ace)
- suits = %w(:spades :hearts :diamonds :clubs)
attr_accessor :hand, :cards
def initialize
- @cards = []
- suits.each do |suit|
- ranks.each do |rank|
+ @cards, @hand = [], []
+ SUITS.each do |suit|
+ RANKS[6..RANKS.length].each do |rank|
@cards << Card.new(rank, suit)
end
end
6.times do @hand << @cards.pop end
end
def deal
initialize
@hand
end
def size
- 24
+ @hand.length
end
def forty?(trump_suit)
(@hand.include? Card.new(:king, trump_suit)) &&
(@hand.include? Card.new(:queen, trump_suit))
end
def twenty?(trump_suit)
end
end
+

Боян обнови решението на 11.11.2015 02:48 (преди около 9 години)

RANKS = %w(2 3 4 5 6 7 8 9 10 :jack :queen :king :ace)
SUITS = %w(:spades :hearts :diamonds :clubs)
class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit = suit
end
- def rank
- @rank
- end
- def suit
- @suit
- end
def to_s
- if @rank.length > 2
- @rank[1..@rank.length].capitalize +
- " of "
- + @suit[1..@suit.length].capitalize
- else @rank + " of " + @suit[1..@suit.length].capitalize
- end
+ @rank.to_s.capitalize + " of " + @suit[0..@suit.length].capitalize
end
end
class Deck
attr_accessor :cards
def initialize
@cards = []
SUITS.each do |suit|
RANKS.reverse.each do |rank|
@cards << Card.new(rank, suit)
end
end
end
def shuffle
cards.shuffle!
end
def sort
initialize
end
def size
@cards.length
end
def draw_top_card
@cards.shift
end
def draw_bottom_card
@cards.pop
end
def top_card
@cards.first
end
def bottom_card
@cards.last
end
def to_s
@cards.each do |card|
puts card.to_s
end
end
- def draw
+ def deal
case
when WarDeck
w = WarDeck.new
w.draw
end
end
end
class WarDeck < Deck
include Enumerable
- attr_accessor :hand, :cards
+ attr_accessor :cards
def initialize
super
- @hand = []
@cards.shuffle!
- 26.times do @hand << @cards.pop end
end
def deal
initialize
- @hand
+ draw = Hand.new
+ 26.times do draw.hand << @cards.pop end
+ draw
end
- def play_card
- @hand.shift
- end
- def allow_face_up?
- @hand.length <= 3
- end
def size
- @hand.length
+ @cards.length
end
+
+ class Hand
+ attr_accessor :hand
+ def initialize
+ @hand = []
+ end
+ def size
+ @hand.length
+ end
+ def allow_face_up?
+ @hand.length <= 3
+ end
+ def play_card
+ @hand.shift
+ end
+ end
+
end
class SixtySixDeck < Deck
- attr_accessor :hand, :cards
+ include Enumerable
+ attr_accessor :cards
def initialize
@cards, @hand = [], []
SUITS.each do |suit|
RANKS[6..RANKS.length].each do |rank|
@cards << Card.new(rank, suit)
end
end
- 6.times do @hand << @cards.pop end
end
def deal
initialize
- @hand
+ draw = Hand.new
+ 6.times do draw.hand << @cards.pop end
+ draw
end
def size
@hand.length
end
- def forty?(trump_suit)
- (@hand.include? Card.new(:king, trump_suit)) &&
- (@hand.include? Card.new(:queen, trump_suit))
- end
- def twenty?(trump_suit)
+ class Hand
+ attr_accessor :hand
+ def initialize
+ @hand = []
+ end
+ def forty?(trump_suit)
+ (@hand.include? Card.new(:king, trump_suit)) &&
+ (@hand.include? Card.new(:queen, trump_suit))
+ end
+ def twenty?(trump_suit)
+ end
+ def size
+ @hand.length
+ end
end
end
+class BeloteDeck < Deck
+end