Assignment 3; due Oct. 21

Posted by admin in Uncategorized Add comments

Classes, Objects, Modules, Tests

12 Responses to “Assignment 3; due Oct. 21”

  1. rainyglade Says:

    Not being a poker aficionado, my question concerns Hand#accept, which says to accept either a single Card or an Array of Card into the hand. Would the Array of Card always be length 5, or could it be of length 2 or 3 or some other number? Could the size even be greater than 5?

  2. john Says:

    Great question.

    The idea is that you would be able to accept any number of cards: 1 (as just a reference to a Card):

    hand.accept( Card.new(0) )

    or 1 inside of an Array — e.g.,

    hand.accept( [ Card.new(0) ] )

    Or multiple cards: 2, 3, 10, whatever:

    hand.accept( [ Card.new(0), Card.new(1), Card.new(20) ] )

    In other words, Hand is highly generic in terms of the number of cards it will accept. With regard to accepting cards, it would work with a card game such as the Irish “Twenty Five,” where the rules say: “The dealer then deals five cards to each person, two at a time followed by three at a time or three at a time followed by two at a time” (http://www.pagat.com/spoil5/25.html).

    As it happens, the tests do not actually check that there are five cards in the hand! It silently assumes that there are 5 cards.

    The upshot of this is that a fancier dealer would probably regulate that everyone has the right number of cards. And if we had had time, the evaluation of cards for a particular game would have been a mix-in. OOPS!! Getting ahead of myself! Maybe I deliberately designed the class so as to help us understand mix-ins later. ;-)

  3. Catherine Says:

    Any and all help with exception handling would be most appreciated! :} thanks

  4. john Says:

    I’ll be talking about exceptions this evening . . .

  5. Darryl Says:

    Couple of possible issues with the tc_spot.rb:

    test_310_hand_strength_120 is defined twice with the second version overwriting the first version

    The second version of test_310_hand_strength_120 actually contains a straight if ace_low is allowed. So if my code has can_handle_ace_low=true, then it fails this test, because I think its a Straight and the tests expects a High Card result

    Is test_320_hand_human_readable_010 missing an assert statement? - it doesn’t appear to do anything at the moment

  6. Darryl Says:

    …and in tc_hand.rb, def test_0195_hand_strength_025 generates a low ace straight flush, which the test expects to just be a flush.

  7. john Says:

    Darryl: That sounds like a bug. I will look at it.

  8. Trung Says:

    In Card, we supposed to create a def for that satisfies “The passed-in object is assumed to expose a card_number method duck-style.”

    Does this means “card_number” is expected to belong to the passed-in object? Or, via duck-style, check if “card_number” method is there? If the latter, then if the “card_number” is not present, then what do we supposed to return (since spaceship’s only valid return values are -1, 0, and 1)?

  9. Trung Says:

    The above comment is for the spaceship method in card. :)

  10. john Says:

    I hope to catch up on a number of little issues with Assignment #3, include the tests that exercise < =>. There is a 90% probability that the test on < => will go away . . .

  11. sagi Says:

    Regarding the latest revision of assignment 3:
    there’s a missing declaration in tc_hand.rb :

    CARD = Card

  12. john Says:

    Sagi: You are right, but if you use “rake test” it doesn’t cause an error, because the constants are defined in one of the other tests.

    But I will fix it nonetheless.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login