jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Hand evaluator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hand evaluator" Watch "Hand evaluator" New topic

Hand evaluator

Charles Angemeyer

Joined: Dec 18, 2012
Posts: 22
This **is** for homework. The code below, that I modified, does the first part of the job and gives me two hands for 5 card poker.
Column 1 is Hand 1 and column 2 is hand two.
How can I evaluate it now and determine whether the hand holds a pair, two pairs, three of a kind, etc?
The professor suggested an array to handle it but I know that we are not supposed to pre-suppose the solution with questions like this.
Any help that you can give me would be most appreciated. Thank you.

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

the first thing you do is....

turn of your computer. Get some paper, some pencils, and some erasers. Start writing down directions as if you were explaining to a child how to evaluate a poker hand. then, revise them. Then revise them again.

I would plan on having several methods. For example, have a method that figures out if you have a flush. Have a method that figures out if you have a straight. Note that these two methods are 100% independent of each other. Once you have those done, then to determine if you have a straight flush, you call both methods and see if they are both true.

In any case, do not write a single line of code until you have steps in clear, plain English, written out on your paper.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link: http://aspose.com/file-tools
subject: Hand evaluator
It's not a secret anymore!