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

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

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

Резултати

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

Код

class Card
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def rank
@rank
end
def suit
@suit
end
def to_s
case @rank
when 2..10
"#{@rank} of #{@suit.capitalize}"
else
"#{@rank.capitalize} of #{@suit.capitalize}"
end
end
def ==(card)
if card.rank == @rank and card.suit == @suit
true
false
end
end
end
class General
include Enumerable
def full_deck
suits = %w(:spades, :hearts, :diamonds, :clubs)
ranks = %w(:ace, :king, :queen, :jack, 10, 9, 8, 7, 6, 5, 4, 3, 2)
suits.each do |suit|
ranks.size.times do |i|
deck << Card.new(ranks[i], suit, i + 1)
end
end
deck
end
def initialize(cards = full_deck) # optional parameter?
@cards = cards
end
def each
current = 0
while current < @cards.size()
yield @cards[counter]
current = current + 1
end
end
def size
@cards.size()
end
def draw_top_card
@cards.pop()
end
def draw_bottom_card
@cards.reverse()
@cards.pop()
@cards.reverse()
end
def top_card
top = @cards.size()
@cards[top - 1]
end
def bottom_card
@cards[0]
end
def shuffle
@cards.shuffle()
end
def get_rank(cards)
case cards.size()
when 52
ranks = %w(:ace, :king, :queen, :jack, 10, 9, 8, 7, 6, 5, 4, 3, 2)
when 32
ranks = %w(:ace, :king, :queen, :jack, 10, 9, 8, 7)
when 24
ranks = %w(:ace, :king, :queen, :jack, 10, 9)
end
ranks
end
def sort
suits, deck = %w(:spades, :hearts, :diamonds, :clubs), fullDeck()
ranksa, copy_cards = get_rank(@cards), @cards
def <=>(other)
suits = %w(:spades, :hearts, :diamonds, :clubs)
(siuts.find_index(self.suit) <=> suits.find_index(other.suit)).nonzero? or
(ranks.find_index(slef.suit) <=> ranks.find_index(other.ranks))
end
deck <=> copy_cards
copy_cards
end
def to_s
counter = 0
while counter < @cards.size()
@cards[counter].to_s
counter = counter + 1
end
end
def deal
counter, hand = 1, Array.new
if @cards.size() == 52
while counter < 27 do hand.push(@cards.pop()) end
elsif @cards.size() == 32
while counter < 9 do hand.push(@cards.pop()) end
else
while counter < 7 do hand.push(@cards.pop()) end
end
hand
end
end
class WarDeck < General
def initialize(cards)
super(cards)
end
def play_card
hand = @cards.deal()
hand.pop()
end
def allow_face_up?
hand = @cards.deal()
if hand.size() < 4
true
else
false
end
end
end
class BeloteDeck < General
def initialize(cards)
super(cards)
end
def _index(card)
ranks = %w(:ace, :king, :queen, :jack, 10, 9, 8, 7)
ranks.find_index(card.rank())
end
def highest_of_suit(suit)
hand, point, max = @cards.deal(), 0, Card.new(2, suit)
while counter < hand.size()
if max.suit == hand[point].suit and _index(max) > _index(hand[point])
max = hand[point]
else
point = point + 1
end
end
max
end
def belote?
counter, yes, hand, belote = 0, false, @cards.deal()
while counter < hand.size()
if hand[counter].rank == :king
belote = hand[counter].suit
end
if (hand[counter].rank == :queen and hand[counter].suit == belote)
yes = true
else counter = counter + 1
end
end
yes
end
def same_cards(in_hand, of_rank)
hand, four_cards, counter = in_hand, Array.new(4), 0
while counter < hand.size()
if hand[counter].rank == of_rank
four_cards.push(hand[counter])
counter = counter + 1
else
counter = counter + 1
end
end
four_cards
end
def carre_of_jacks?
hand = @cards.deal()
carre = same_cards(hand, :jack)
if carre.size() == 4
true
else
false
end
end
def carre_of_queens?
hand = @cards.deal()
carre = same_cards(hand, :queen)
if carre.size() == 4
true
else
false
end
end
def carre_of_kings?
hand = @cards.deal()
carre = same_cards(hand, :king)
if carre.size() == 4
true
else
false
end
end
def carre_of_aces?
hand = @cards.deal()
carre = same_cards(hand, :ace)
if carre.size() == 4
true
else
false
end
end
end

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

..FFF.FFFFFFFFFFFF.FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

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:0x007ff9959b5730 @rank=4, @suit=:spades>
            got: #<Card:0x007ff9959b5780 @rank=4, @suit=:spades>
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007ff9959b5730 @rank=4, @suit=:spades>
       +#<Card:0x007ff9959b5780 @rank=4, @suit=:spades>
     # /tmp/d20151112-27349-16k4mvb/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: expect(small_deck.to_a).to eq [ace_of_spades, nine_of_clubs]
     NameError:
       undefined local variable or method `counter' for #<WarDeck:0x007ff995998c48>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:140
     # /tmp/d20151112-27349-16k4mvb/solution.rb:47:in `each'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:11:in `to_a'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:11: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: deck = deck_class.new
     ArgumentError:
       wrong number of arguments (0 for 1)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:140
     # /tmp/d20151112-27349-16k4mvb/solution.rb:116:in `initialize'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:15:in `new'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:15: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 #draw_top_card pops the top-most card
     Failure/Error: expect(small_deck.draw_top_card).to eq ace_of_spades
       
       expected: #<Card:0x007ff9967fe238 @rank=:ace, @suit=:spades>
            got: #<Card:0x007ff9967fe210 @rank=9, @suit=:clubs>
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007ff9967fe238 @rank=:ace, @suit=:spades>
       +#<Card:0x007ff9967fe210 @rank=9, @suit=:clubs>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:140
     # /tmp/d20151112-27349-16k4mvb/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)>'

  5) WarDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: expect(small_deck.draw_bottom_card).to eq nine_of_clubs
       
       expected: #<Card:0x007ff996821c60 @rank=9, @suit=:clubs>
            got: [#<Card:0x007ff996821c88 @rank=:ace, @suit=:spades>]
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007ff996821c60 @rank=9, @suit=:clubs>
       +[#<Card:0x007ff996821c88 @rank=:ace, @suit=:spades>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:140
     # /tmp/d20151112-27349-16k4mvb/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)>'

  6) WarDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: expect(small_deck.top_card).to eq ace_of_spades
       
       expected: #<Card:0x007ff9967908c8 @rank=:ace, @suit=:spades>
            got: #<Card:0x007ff9967908a0 @rank=9, @suit=:clubs>
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007ff9967908c8 @rank=:ace, @suit=:spades>
       +#<Card:0x007ff9967908a0 @rank=9, @suit=:clubs>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:140
     # /tmp/d20151112-27349-16k4mvb/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)>'

  7) WarDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: expect(small_deck.bottom_card).to eq nine_of_clubs
       
       expected: #<Card:0x007ff99684a840 @rank=9, @suit=:clubs>
            got: #<Card:0x007ff99684a868 @rank=:ace, @suit=:spades>
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007ff99684a840 @rank=9, @suit=:clubs>
       +#<Card:0x007ff99684a868 @rank=:ace, @suit=:spades>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:140
     # /tmp/d20151112-27349-16k4mvb/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)>'

  8) WarDeck behaves like a deck #shuffle does not remove cards from the deck
     Failure/Error: deck = deck_class.new
     ArgumentError:
       wrong number of arguments (0 for 1)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:140
     # /tmp/d20151112-27349-16k4mvb/solution.rb:116:in `initialize'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:57:in `new'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:57: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: expect(small_deck.to_s.strip).to eq "Ace of Spades\n9 of Clubs"
     NoMethodError:
       undefined method `strip' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:140
     # /tmp/d20151112-27349-16k4mvb/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: expect(deck.sort.to_a).to eq [jack_of_spades, ten_of_hearts, ace_of_clubs, two_of_clubs]
     NoMethodError:
       undefined method `fullDeck' for #<WarDeck:0x007ff9967f5570>
     # /tmp/d20151112-27349-16k4mvb/solution.rb:84:in `sort'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:155: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) WarDeck hand #deal deals 26 cards
     Failure/Error: hand = WarDeck.new.deal
     ArgumentError:
       wrong number of arguments (0 for 1)
     # /tmp/d20151112-27349-16k4mvb/solution.rb:116:in `initialize'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:162:in `new'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:162: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)>'

  12) WarDeck hand #allow_face_up? returns false if the cards are more than 3
     Failure/Error: let(:hand) { WarDeck.new.deal }
     ArgumentError:
       wrong number of arguments (0 for 1)
     # /tmp/d20151112-27349-16k4mvb/solution.rb:116:in `initialize'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:169:in `new'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:169:in `block (4 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:172: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)>'

  13) WarDeck hand #allow_face_up? returns true if the cards are less than or equal to 3
     Failure/Error: let(:hand) { WarDeck.new.deal }
     ArgumentError:
       wrong number of arguments (0 for 1)
     # /tmp/d20151112-27349-16k4mvb/solution.rb:116:in `initialize'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:169:in `new'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:169:in `block (4 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:176:in `block (5 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:176:in `times'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:176: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)>'

  14) BeloteDeck behaves like a deck implements Enumerable
     Failure/Error: expect(small_deck.to_a).to eq [ace_of_spades, nine_of_clubs]
     NameError:
       undefined local variable or method `counter' for #<BeloteDeck:0x007ff9967c3a70>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:191
     # /tmp/d20151112-27349-16k4mvb/solution.rb:47:in `each'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:11:in `to_a'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:11: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)>'

  15) BeloteDeck behaves like a deck fills the deck if no initialize parameters are given
     Failure/Error: deck = deck_class.new
     ArgumentError:
       wrong number of arguments (0 for 1)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:191
     # /tmp/d20151112-27349-16k4mvb/solution.rb:135:in `initialize'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:15:in `new'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:15: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)>'

  16) BeloteDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: expect(small_deck.draw_top_card).to eq ace_of_spades
       
       expected: #<Card:0x007ff9967add38 @rank=:ace, @suit=:spades>
            got: #<Card:0x007ff9967add10 @rank=9, @suit=:clubs>
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007ff9967add38 @rank=:ace, @suit=:spades>
       +#<Card:0x007ff9967add10 @rank=9, @suit=:clubs>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:191
     # /tmp/d20151112-27349-16k4mvb/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)>'

  17) BeloteDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: expect(small_deck.draw_bottom_card).to eq nine_of_clubs
       
       expected: #<Card:0x007ff996752258 @rank=9, @suit=:clubs>
            got: [#<Card:0x007ff9967522d0 @rank=:ace, @suit=:spades>]
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007ff996752258 @rank=9, @suit=:clubs>
       +[#<Card:0x007ff9967522d0 @rank=:ace, @suit=:spades>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:191
     # /tmp/d20151112-27349-16k4mvb/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)>'

  18) BeloteDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: expect(small_deck.top_card).to eq ace_of_spades
       
       expected: #<Card:0x007ff9967135a8 @rank=:ace, @suit=:spades>
            got: #<Card:0x007ff996713580 @rank=9, @suit=:clubs>
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007ff9967135a8 @rank=:ace, @suit=:spades>
       +#<Card:0x007ff996713580 @rank=9, @suit=:clubs>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:191
     # /tmp/d20151112-27349-16k4mvb/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)>'

  19) BeloteDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: expect(small_deck.bottom_card).to eq nine_of_clubs
       
       expected: #<Card:0x007ff9966ed330 @rank=9, @suit=:clubs>
            got: #<Card:0x007ff9966ed358 @rank=:ace, @suit=:spades>
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007ff9966ed330 @rank=9, @suit=:clubs>
       +#<Card:0x007ff9966ed358 @rank=:ace, @suit=:spades>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:191
     # /tmp/d20151112-27349-16k4mvb/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)>'

  20) BeloteDeck behaves like a deck #shuffle does not remove cards from the deck
     Failure/Error: deck = deck_class.new
     ArgumentError:
       wrong number of arguments (0 for 1)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:191
     # /tmp/d20151112-27349-16k4mvb/solution.rb:135:in `initialize'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:57:in `new'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:57: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)>'

  21) BeloteDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: expect(small_deck.to_s.strip).to eq "Ace of Spades\n9 of Clubs"
     NoMethodError:
       undefined method `strip' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:191
     # /tmp/d20151112-27349-16k4mvb/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)>'

  22) BeloteDeck #sort sorts the cards in the defined order
     Failure/Error: expect(deck.sort.to_a).to eq [jack_of_spades, ten_of_hearts, ace_of_clubs, seven_of_clubs]
     NoMethodError:
       undefined method `fullDeck' for #<BeloteDeck:0x007ff99669fb08>
     # /tmp/d20151112-27349-16k4mvb/solution.rb:84:in `sort'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:206: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)>'

  23) BeloteDeck hand #deal deals 8 cards
     Failure/Error: hand = BeloteDeck.new.deal
     ArgumentError:
       wrong number of arguments (0 for 1)
     # /tmp/d20151112-27349-16k4mvb/solution.rb:135:in `initialize'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:213:in `new'
     # /tmp/d20151112-27349-16k4mvb/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)>'

  24) BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:230: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)>'

  25) BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:249: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)>'

  26) BeloteDeck hand #belote? returns false when there is no king and queen of the same suit
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:264: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)>'

  27) BeloteDeck hand #tierce? with tierce returns true for cards with names
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:282: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)>'

  28) BeloteDeck hand #tierce? with tierce returns true for cards with numbers
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:297: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)>'

  29) BeloteDeck hand #tierce? without tierce does not confuse cards with different suits
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:314: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)>'

  30) BeloteDeck hand #quarte? detects four cards with increasing ranks
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:332: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 #quarte? does not return true if there is no quarte
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:347: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)>'

  32) BeloteDeck hand #quint? detects five cards with increasing ranks
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:364: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)>'

  33) BeloteDeck hand #quint? does not return true if there is no quint
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:379: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)>'

  34) BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-16k4mvb/spec.rb:386
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:84: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_jacks? behaves like carre-checking method returns false when there is no carre
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-16k4mvb/spec.rb:386
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:99: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_nines? behaves like carre-checking method returns true when there is a carre
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-16k4mvb/spec.rb:390
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:84: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) BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns false when there is no carre
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-16k4mvb/spec.rb:390
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:99: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) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-16k4mvb/spec.rb:394
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:84: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) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns false when there is no carre
     Failure/Error: ]).deal
     Timeout::Error:
       execution expired
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-16k4mvb/spec.rb:394
     # /tmp/d20151112-27349-16k4mvb/solution.rb:108:in `deal'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:99: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)>'

  40) SixtySixDeck behaves like a deck implements Enumerable
     Failure/Error: subject(:deck_class) { Object.const_get(klass) }
     NameError:
       uninitialized constant SixtySixDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:400
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `const_get'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/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)>'

  41) SixtySixDeck behaves like a deck fills the deck if no initialize parameters are given
     Failure/Error: subject(:deck_class) { Object.const_get(klass) }
     NameError:
       uninitialized constant SixtySixDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:400
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `const_get'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:15: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)>'

  42) SixtySixDeck behaves like a deck #size returns the size of the deck
     Failure/Error: subject(:deck_class) { Object.const_get(klass) }
     NameError:
       uninitialized constant SixtySixDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:400
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `const_get'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/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)>'

  43) SixtySixDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: subject(:deck_class) { Object.const_get(klass) }
     NameError:
       uninitialized constant SixtySixDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:400
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `const_get'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/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)>'

  44) SixtySixDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: subject(:deck_class) { Object.const_get(klass) }
     NameError:
       uninitialized constant SixtySixDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:400
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `const_get'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/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)>'

  45) SixtySixDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: subject(:deck_class) { Object.const_get(klass) }
     NameError:
       uninitialized constant SixtySixDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:400
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `const_get'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/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)>'

  46) SixtySixDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: subject(:deck_class) { Object.const_get(klass) }
     NameError:
       uninitialized constant SixtySixDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:400
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `const_get'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/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)>'

  47) SixtySixDeck behaves like a deck #shuffle does not remove cards from the deck
     Failure/Error: subject(:deck_class) { Object.const_get(klass) }
     NameError:
       uninitialized constant SixtySixDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:400
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `const_get'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:57: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)>'

  48) SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: subject(:deck_class) { Object.const_get(klass) }
     NameError:
       uninitialized constant SixtySixDeck
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-16k4mvb/spec.rb:400
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `const_get'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:2:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-16k4mvb/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)>'

  49) SixtySixDeck #sort sorts the cards in the defined order
     Failure/Error: deck = SixtySixDeck.new(cards)
     NameError:
       uninitialized constant SixtySixDeck
     # /tmp/d20151112-27349-16k4mvb/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)>'

  50) SixtySixDeck hand #deal deals 6 cards
     Failure/Error: hand = SixtySixDeck.new.deal
     NameError:
       uninitialized constant SixtySixDeck
     # /tmp/d20151112-27349-16k4mvb/spec.rb:422: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)>'

  51) SixtySixDeck hand #twenty? returns true for king and queen not of the trump suit
     Failure/Error: hand = SixtySixDeck.new([
     NameError:
       uninitialized constant SixtySixDeck
     # /tmp/d20151112-27349-16k4mvb/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)>'

  52) SixtySixDeck hand #twenty? returns false for king and queen of the trump suit
     Failure/Error: hand = SixtySixDeck.new([
     NameError:
       uninitialized constant SixtySixDeck
     # /tmp/d20151112-27349-16k4mvb/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)>'

  53) SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit
     Failure/Error: hand = SixtySixDeck.new([
     NameError:
       uninitialized constant SixtySixDeck
     # /tmp/d20151112-27349-16k4mvb/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 17.76 seconds
57 examples, 53 failures

Failed examples:

rspec /tmp/d20151112-27349-16k4mvb/spec.rb:130 # Card #== compares two cards by their rank and suit
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:8 # WarDeck behaves like a deck implements Enumerable
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:14 # WarDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:28 # WarDeck behaves like a deck #draw_top_card pops the top-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:35 # WarDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:42 # WarDeck behaves like a deck #top peeks at the top-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:49 # WarDeck behaves like a deck #bottom peeks at the bottom-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:56 # WarDeck behaves like a deck #shuffle does not remove cards from the deck
rspec /tmp/d20151112-27349-16k4mvb/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-16k4mvb/spec.rb:145 # WarDeck #sort sorts the cards in the defined order
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:161 # WarDeck hand #deal deals 26 cards
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:171 # WarDeck hand #allow_face_up? returns false if the cards are more than 3
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:175 # WarDeck hand #allow_face_up? returns true if the cards are less than or equal to 3
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:8 # BeloteDeck behaves like a deck implements Enumerable
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:14 # BeloteDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:28 # BeloteDeck behaves like a deck #draw_top_card pops the top-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:35 # BeloteDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:42 # BeloteDeck behaves like a deck #top peeks at the top-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:49 # BeloteDeck behaves like a deck #bottom peeks at the bottom-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:56 # BeloteDeck behaves like a deck #shuffle does not remove cards from the deck
rspec /tmp/d20151112-27349-16k4mvb/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-16k4mvb/spec.rb:196 # BeloteDeck #sort sorts the cards in the defined order
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:212 # BeloteDeck hand #deal deals 8 cards
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:220 # BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:239 # BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:254 # BeloteDeck hand #belote? returns false when there is no king and queen of the same suit
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:272 # BeloteDeck hand #tierce? with tierce returns true for cards with names
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:287 # BeloteDeck hand #tierce? with tierce returns true for cards with numbers
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:304 # BeloteDeck hand #tierce? without tierce does not confuse cards with different suits
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:322 # BeloteDeck hand #quarte? detects four cards with increasing ranks
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:337 # BeloteDeck hand #quarte? does not return true if there is no quarte
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:354 # BeloteDeck hand #quint? detects five cards with increasing ranks
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:369 # BeloteDeck hand #quint? does not return true if there is no quint
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:74 # BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:89 # BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns false when there is no carre
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:74 # BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:89 # BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns false when there is no carre
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:74 # BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:89 # BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns false when there is no carre
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:8 # SixtySixDeck behaves like a deck implements Enumerable
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:14 # SixtySixDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:22 # SixtySixDeck behaves like a deck #size returns the size of the deck
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:28 # SixtySixDeck behaves like a deck #draw_top_card pops the top-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:35 # SixtySixDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:42 # SixtySixDeck behaves like a deck #top peeks at the top-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:49 # SixtySixDeck behaves like a deck #bottom peeks at the bottom-most card
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:56 # SixtySixDeck behaves like a deck #shuffle does not remove cards from the deck
rspec /tmp/d20151112-27349-16k4mvb/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-16k4mvb/spec.rb:405 # SixtySixDeck #sort sorts the cards in the defined order
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:421 # SixtySixDeck hand #deal deals 6 cards
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:429 # SixtySixDeck hand #twenty? returns true for king and queen not of the trump suit
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:442 # SixtySixDeck hand #twenty? returns false for king and queen of the trump suit
rspec /tmp/d20151112-27349-16k4mvb/spec.rb:455 # SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit

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

Емилия обнови решението на 10.11.2015 22:25 (преди над 8 години)

+class Card
+ def initialize(rank, suit)
+ @rank = rank
+ @suit = suit
+ end
+ def rank
+ @rank
+ end
+ def suit
+ @suit
+ end
+ def to_s
+ case @rank
+ when 2..10
+ "#{@rank} of #{@suit.capitalize}"
+ else
+ "#{@rank.capitalize} of #{@suit.capitalize}"
+ end
+ end
+ def ==(card)
+ if card.rank == @rank and card.suit == @suit
+ true
+ false
+ end
+ end
+end
+
+
+class General
+ include Enumerable
+ def full_deck
+ suits = %w(:spades, :hearts, :diamonds, :clubs)
+ ranks = %w(:ace, :king, :queen, :jack, 10, 9, 8, 7, 6, 5, 4, 3, 2)
+ suits.each do |suit|
+ ranks.size.times do |i|
+ deck << Card.new(ranks[i], suit, i + 1)
+ end
+ end
+ deck
+ end
+ def initialize(cards = full_deck) # optional parameter?
+ @cards = cards
+ end
+ def each
+ current = 0
+ while current < @cards.size()
+ yield @cards[counter]
+ current = current + 1
+ end
+ end
+ def size
+ @cards.size()
+ end
+ def draw_top_card
+ @cards.pop()
+ end
+ def draw_bottom_card
+ @cards.reverse()
+ @cards.pop()
+ @cards.reverse()
+ end
+ def top_card
+ top = @cards.size()
+ @cards[top - 1]
+ end
+ def bottom_card
+ @cards[0]
+ end
+ def shuffle
+ @cards.shuffle()
+ end
+ def get_rank(cards)
+ case cards.size()
+ when 52
+ ranks = %w(:ace, :king, :queen, :jack, 10, 9, 8, 7, 6, 5, 4, 3, 2)
+ when 32
+ ranks = %w(:ace, :king, :queen, :jack, 10, 9, 8, 7)
+ when 24
+ ranks = %w(:ace, :king, :queen, :jack, 10, 9)
+ end
+ ranks
+ end
+ def sort
+ suits, deck = %w(:spades, :hearts, :diamonds, :clubs), fullDeck()
+ ranksa, copy_cards = get_rank(@cards), @cards
+ def <=>(other)
+ suits = %w(:spades, :hearts, :diamonds, :clubs)
+ (siuts.find_index(self.suit) <=> suits.find_index(other.suit)).nonzero? or
+ (ranks.find_index(slef.suit) <=> ranks.find_index(other.ranks))
+ end
+ deck <=> copy_cards
+ copy_cards
+ end
+ def to_s
+ counter = 0
+ while counter < @cards.size()
+ @cards[counter].to_s
+ counter = counter + 1
+ end
+ end
+ def deal
+ counter, hand = 1, Array.new
+ if @cards.size() == 52
+ while counter < 27 do hand.push(@cards.pop()) end
+ elsif @cards.size() == 32
+ while counter < 9 do hand.push(@cards.pop()) end
+ else
+ while counter < 7 do hand.push(@cards.pop()) end
+ end
+ hand
+ end
+end
+
+
+class WarDeck < General
+ def initialize(cards)
+ super(cards)
+ end
+ def play_card
+ hand = @cards.deal()
+ hand.pop()
+ end
+ def allow_face_up?
+ hand = @cards.deal()
+ if hand.size() < 4
+ true
+ else
+ false
+ end
+ end
+end
+
+
+class BeloteDeck < General
+ def initialize(cards)
+ super(cards)
+ end
+ def _index(card)
+ ranks = %w(:ace, :king, :queen, :jack, 10, 9, 8, 7)
+ ranks.find_index(card.rank())
+ end
+ def highest_of_suit(suit)
+ hand, point, max = @cards.deal(), 0, Card.new(2, suit)
+ while counter < hand.size()
+ if max.suit == hand[point].suit and _index(max) > _index(hand[point])
+ max = hand[point]
+ else
+ point = point + 1
+ end
+ end
+ max
+ end
+ def belote?
+ counter, yes, hand, belote = 0, false, @cards.deal()
+ while counter < hand.size()
+ if hand[counter].rank == :king
+ belote = hand[counter].suit
+ end
+ if (hand[counter].rank == :queen and hand[counter].suit == belote)
+ yes = true
+ else counter = counter + 1
+ end
+ end
+ yes
+ end
+ def same_cards(in_hand, of_rank)
+ hand, four_cards, counter = in_hand, Array.new(4), 0
+ while counter < hand.size()
+ if hand[counter].rank == of_rank
+ four_cards.push(hand[counter])
+ counter = counter + 1
+ else
+ counter = counter + 1
+ end
+ end
+ four_cards
+ end
+ def carre_of_jacks?
+ hand = @cards.deal()
+ carre = same_cards(hand, :jack)
+ if carre.size() == 4
+ true
+ else
+ false
+ end
+ end
+ def carre_of_queens?
+ hand = @cards.deal()
+ carre = same_cards(hand, :queen)
+ if carre.size() == 4
+ true
+ else
+ false
+ end
+ end
+ def carre_of_kings?
+ hand = @cards.deal()
+ carre = same_cards(hand, :king)
+ if carre.size() == 4
+ true
+ else
+ false
+ end
+ end
+ def carre_of_aces?
+ hand = @cards.deal()
+ carre = same_cards(hand, :ace)
+ if carre.size() == 4
+ true
+ else
+ false
+ end
+ end
+end