Saturday 10 December 2011

Java: Texas Hold Em (17) - Weekend Post

Heh, almost forgot about saying I'd do this for 2 weekends :P Since it's the weekend and everyone probably just wants to chill, I'll keep it short and sweet.

We're starting with the HandValue class, and what this does, basically, actually gives some representation to the value got by the evaluator, complete with a toString() method and a way to compare hands! As a general blueprint, we need:



A hand to actually work with.
A constructor that should evaluate (using HandEvaluator) the hand, and extract it's info.
Public get...() methods so a user can get the Hand, and HandValueType's Type and Description.
Another get..() method to get the score value from HandEvaluator.
We'll also, as part of the comparison functionality, want 2 methods, equals() and compareTo().
Finally, we just need a toString() method just so we can actually represent stuff easily.

Stigter has a hashCode method, but I don't see much use for it. No idea what it's for, but it just returns the value, same as getValue(). Maybe I'll have to put it in later? He's been right about almost everything so far, after all!


As you can see, unless I forgot something, the blueprint makes this class look pretty small, fairly easy to pull off, and not at all time-consuming. This is a big contrast to the class we just got done with, so yay, welcome break!

I think the blueprint is enough on it's own for a weekend post, don't you? Tomorrow we can get started on the real deal, perhaps going through the constructor and instance variables! See you then! Questions and comments welcome!


Visit http://www.deltainterface.com for public domain books, movies and music! I hear it's been updated! Feedback to the provided emails would be helpful!

3 comments:

  1. Thanks for sharing that website. ;)

    ReplyDelete
  2. So does this mean you'll be posting on Sundays too?

    ReplyDelete
  3. I'm learning to program in C atm, should be interesting to see the differences in languages.

    ReplyDelete