Download - Java Poker

Transcript
  • Load the basic Java bridge functionality.

    Load the Java.util package, forRuby-side access to ArrayList.

    ArrayList comes from java.util, andis visible thanks to the include_package directive.

    Prompt the user for a simplecard-by-card input series.

    Report error to user and ask forre-input of the specs for this card.

    PokerHand includes a rating method, which returns a string indicating thecontent of the hand (e.g., PAIR).

    Start the input loop, tracking thenumber to use in the prompt.

    On malformed input, raise an exception oftype InvalidCardException, which is definedin the com.dablack.cards Java package.

    Load the locally-written cardsJava package.

    The PokerHand class comes from thecom.dablack.cards package, and isvisible in Ruby because that packagewas imported.

    Intercept (rescue from) the exceptionInvalidCardException, which the Javaconstructor throws if the suit and rank ofa card are not recognizable.

    The built-in Ruby times method (onFixnum objects) yields a number eachtime through its code block.

    get_a_card is the subroutine/methodfor getting user input, in the style of5/diamonds, and returning a newCard object built from that input.

    The Card class is defined in theJava package com.dablack.cards.

    PokerHand includes a rating method, which returns a string indicating thecontent of the hand (e.g., PAIR).

    Start the demo by instantiatingthe containing class andcalling go. .

    The constructor for the Java (and nowRuby) Card class takes two arguments.

    HandEvaluator will serve as theclass for demo-ing the evaluationof a poker hand.

    ACM Learning Center -- Ruby Learning PathCopyright 2011, Ruby Power and Light, LLC

    Slide 1


Top Related