Решение на Четвърта задача от Николай Станев
Резултати
- 4 точки от тестове
- 0 бонус точки
- 4 точки общо
- 34 успешни тест(а)
- 23 неуспешни тест(а)
Код
Лог от изпълнението
...........Ace of Spades 9 of Clubs F...F........Ace of Spades 9 of Clubs F..FFFFFFFFFFFFFFFF........Ace of Spades 9 of Clubs F..FFF Failures: 1) 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 #<Array:0x007f0f5b0d0018> Shared Example Group: "a deck" called from /tmp/d20151112-27349-1o3ajcp/spec.rb:140 # /tmp/d20151112-27349-1o3ajcp/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)>' 2) WarDeck hand #allow_face_up? returns true if the cards are less than or equal to 3 Failure/Error: expect(hand.allow_face_up?).to eq true expected: true got: false (compared using ==) # /tmp/d20151112-27349-1o3ajcp/spec.rb:178: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)>' 3) 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 #<Array:0x007f0f5b017c98> Shared Example Group: "a deck" called from /tmp/d20151112-27349-1o3ajcp/spec.rb:191 # /tmp/d20151112-27349-1o3ajcp/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)>' 4) BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit Failure/Error: expect(hand.highest_of_suit(:clubs)).to eq Card.new(:ace, :clubs) NoMethodError: undefined method `highest_of_suit' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:232: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)>' 5) BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit Failure/Error: expect(hand.belote?).to be true NoMethodError: undefined method `belote?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:251: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)>' 6) BeloteDeck hand #belote? returns false when there is no king and queen of the same suit Failure/Error: expect(hand.belote?).to be false NoMethodError: undefined method `belote?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:266: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)>' 7) BeloteDeck hand #tierce? with tierce returns true for cards with names Failure/Error: expect(hand.tierce?).to be true NoMethodError: undefined method `tierce?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:284: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)>' 8) BeloteDeck hand #tierce? with tierce returns true for cards with numbers Failure/Error: expect(hand.tierce?).to be true NoMethodError: undefined method `tierce?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:299: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)>' 9) BeloteDeck hand #tierce? without tierce does not confuse cards with different suits Failure/Error: expect(hand.tierce?).to be false NoMethodError: undefined method `tierce?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:316: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)>' 10) BeloteDeck hand #quarte? detects four cards with increasing ranks Failure/Error: expect(hand.quarte?).to be true NoMethodError: undefined method `quarte?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:334: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)>' 11) BeloteDeck hand #quarte? does not return true if there is no quarte Failure/Error: expect(hand.quarte?).to be false NoMethodError: undefined method `quarte?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:349: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) BeloteDeck hand #quint? detects five cards with increasing ranks Failure/Error: expect(hand.quint?).to be true NoMethodError: undefined method `quint?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:366: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) BeloteDeck hand #quint? does not return true if there is no quint Failure/Error: expect(hand.quint?).to be false NoMethodError: undefined method `quint?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:381: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 hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre Failure/Error: expect(hand.public_send(method)).to be true NoMethodError: undefined method `carre_of_jacks?' for nil:NilClass Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1o3ajcp/spec.rb:386 # /tmp/d20151112-27349-1o3ajcp/spec.rb:86:in `public_send' # /tmp/d20151112-27349-1o3ajcp/spec.rb:86: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 hand #carre_of_jacks? behaves like carre-checking method returns false when there is no carre Failure/Error: expect(hand.public_send(method)).to be false NoMethodError: undefined method `carre_of_jacks?' for nil:NilClass Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1o3ajcp/spec.rb:386 # /tmp/d20151112-27349-1o3ajcp/spec.rb:101:in `public_send' # /tmp/d20151112-27349-1o3ajcp/spec.rb:101: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 hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre Failure/Error: expect(hand.public_send(method)).to be true NoMethodError: undefined method `carre_of_nines?' for nil:NilClass Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1o3ajcp/spec.rb:390 # /tmp/d20151112-27349-1o3ajcp/spec.rb:86:in `public_send' # /tmp/d20151112-27349-1o3ajcp/spec.rb:86: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)>' 17) BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns false when there is no carre Failure/Error: expect(hand.public_send(method)).to be false NoMethodError: undefined method `carre_of_nines?' for nil:NilClass Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1o3ajcp/spec.rb:390 # /tmp/d20151112-27349-1o3ajcp/spec.rb:101:in `public_send' # /tmp/d20151112-27349-1o3ajcp/spec.rb:101: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)>' 18) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre Failure/Error: expect(hand.public_send(method)).to be true NoMethodError: undefined method `carre_of_aces?' for nil:NilClass Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1o3ajcp/spec.rb:394 # /tmp/d20151112-27349-1o3ajcp/spec.rb:86:in `public_send' # /tmp/d20151112-27349-1o3ajcp/spec.rb:86: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)>' 19) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns false when there is no carre Failure/Error: expect(hand.public_send(method)).to be false NoMethodError: undefined method `carre_of_aces?' for nil:NilClass Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1o3ajcp/spec.rb:394 # /tmp/d20151112-27349-1o3ajcp/spec.rb:101:in `public_send' # /tmp/d20151112-27349-1o3ajcp/spec.rb:101: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)>' 20) SixtySixDeck 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 #<Array:0x007f0f5ae69f68> Shared Example Group: "a deck" called from /tmp/d20151112-27349-1o3ajcp/spec.rb:400 # /tmp/d20151112-27349-1o3ajcp/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)>' 21) SixtySixDeck hand #twenty? returns true for king and queen not of the trump suit Failure/Error: expect(hand.twenty?(:hearts)).to be true NoMethodError: undefined method `twenty?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:439: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) SixtySixDeck hand #twenty? returns false for king and queen of the trump suit Failure/Error: expect(hand.twenty?(:clubs)).to be false NoMethodError: undefined method `twenty?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:452: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) SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit Failure/Error: expect(hand.twenty?(:hearts)).to be false NoMethodError: undefined method `twenty?' for nil:NilClass # /tmp/d20151112-27349-1o3ajcp/spec.rb:465: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.03688 seconds 57 examples, 23 failures Failed examples: rspec /tmp/d20151112-27349-1o3ajcp/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-1o3ajcp/spec.rb:175 # WarDeck hand #allow_face_up? returns true if the cards are less than or equal to 3 rspec /tmp/d20151112-27349-1o3ajcp/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-1o3ajcp/spec.rb:220 # BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:239 # BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:254 # BeloteDeck hand #belote? returns false when there is no king and queen of the same suit rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:272 # BeloteDeck hand #tierce? with tierce returns true for cards with names rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:287 # BeloteDeck hand #tierce? with tierce returns true for cards with numbers rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:304 # BeloteDeck hand #tierce? without tierce does not confuse cards with different suits rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:322 # BeloteDeck hand #quarte? detects four cards with increasing ranks rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:337 # BeloteDeck hand #quarte? does not return true if there is no quarte rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:354 # BeloteDeck hand #quint? detects five cards with increasing ranks rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:369 # BeloteDeck hand #quint? does not return true if there is no quint rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:74 # BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:89 # BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns false when there is no carre rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:74 # BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:89 # BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns false when there is no carre rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:74 # BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:89 # BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns false when there is no carre rspec /tmp/d20151112-27349-1o3ajcp/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-1o3ajcp/spec.rb:429 # SixtySixDeck hand #twenty? returns true for king and queen not of the trump suit rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:442 # SixtySixDeck hand #twenty? returns false for king and queen of the trump suit rspec /tmp/d20151112-27349-1o3ajcp/spec.rb:455 # SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit
История (6 версии и 3 коментара)
Николай обнови решението на 11.11.2015 09:10 (преди около 9 години)
Ники, намери начин да разкараш метода convert_name
. Има лошо именуване вътре и като цяло, този метод прави някаква откачена работа, от която няма никаква нужда. Има начин да стане и без него.
Не оставяй puts
в кода си. Ако има грешки и ако държиш да ги обработиш, въпреки, че това не се иска по условие, хвърляй изключение.
На места имаш сериозни стилови проблеми. Опитай да намериш начин да ги идентифицираш и премахнеш. За груби нарушения в стила е възможно да отнемем точки.
Намери начин и да си пуснеш примерните тестове. Ако нещо гърми, дай пълната команда с това как ги пускаш, както и точната грешка тук.
Николай обнови решението на 11.11.2015 11:35 (преди около 9 години)
Николай обнови решението на 11.11.2015 11:54 (преди около 9 години)
Николай обнови решението на 11.11.2015 11:56 (преди около 9 години)
Николай обнови решението на 11.11.2015 15:17 (преди около 9 години)
Имаш излишни присвоявания и ненужни if
-ове на места (вж. класа Card
).
Имаш проблеми със спазването на конвенциите на места, направи справка с ръководството за стил.
Прегледай решенията на колеги и нашето примерно решение за алтернативни идеи.