Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hand evaluator

 
Charles Angemeyer
Greenhorn
Posts: 22
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 12146
30
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic