Hey guys, maybe someone can help me, I am working on a problem for class and it is from the Deitel java book. Chapter 7 problem 31, It has to do with calling a straight function. I have it calling the full house, pair, two pair, and flush. How do I see if there is striaght? My cards are strings numbered Ace, Duece, Three... Not ints 1, 2, 3... So how can I determine if Duece+1 == Three? Can anyone help me out on this???
I don't have that book so I can't speak to the specifics of your problem although I once wrote a program that did poker calculations from scratch. I would suggest creating a Card Class (if you don't have one all ready). Then you can add a property to the class such as card.getNumericValue().
For a straight, you just take the card with the lowest numeric value (cost of O(n) to find min card) then determine if remaining cards have values x+1, x+2, x+3 etc (Cost of O(5*n) total where n is 5 for 5-card poker, so very fast technique). You do need to put some special logic in their for aces but the case of aces happens so rarely that its not a difficult specific case to write. Probably could be handled with one if statement such as, if the lowest card value is 2, check if there exists an ACE (with value 14) then reset that as the lowest card and look for 2 though 5.