[java] Contiguous Array Test
I'm writing a client-server poker-tournament game (which I later want to extend to playing other games) and have started on the part where the system analyses the hand a given player has.
I have a jCard object that represents a card. A player's hand is represented by a jHand object that contains a Stack, which contains a set of jCards.
jCard properties are:
String suit; (Text version of suit, i.e. "Clubs", "Diamonds" etc)
String code; (2 char code 1st Char = suit, 2nd char = value - i.e. HK = King of Hearts)
int value; 1-13 (Aces through Kings)
So, I've another object called a jHandAnalyser that has a number of methods for checking what a hand might be worth. The main property of this object is a jHand reference called myHand.
Calling the constructor of jHandAnalyser passes in the hand you want to analyse. e.g.
jHandAnalyser aPlayer = new jHandAnalyser(aHand);
This jHandAnalyser needs to look at the jHand object it's given and decide what the hand is worth.
So far I have a method called isFlush() that returns true if the cards are all of the same suit, but am wondering how to implement the isStrait (sp?) method. i.e. I want to check that all the cards are in a sequential run. Has anyone got any ideas how I can do this nice and cleanly?
|