I merged your stuff with the following thread. I hope that is okay by you.
posted 1 week ago
Each player will have 2 cards in hand.
On board there will be 5 cards.
Pick the best hand with five cards (best 5 cards from 7 cards)
I need ideas for evaluating hands.
posted 1 week ago
I think these two topics are so similar that they sould be discussed as one. I have joined the two discussions.
I am pleased to see you indenting your code, but some of yur lines (e.g. line 71) are too long and should be broken into two lines.
Don't use \n, and don't terminate what you are returning from toString() with a line end sequence (line 83). Write return rank + " of " + suit; Leave it to the method's user to decide whether to use println() or print() or similar.
I can see two serious problems. You have fields which are not marked private.
You have duplicated data structures, particularly the enums, which appear twice each. Such enums should be written as top‑level types, not nested types.
There are lots of minor problems, which will lose you marks, but I shall keep quiet about them for now.
Don't use Strings to pass information. You can pass the enum elements directly. Looks at lines 44 and 76.
This merging is not very handy. I wanted to reply to the topic of comparing twp pokerhands, only to end up in this topic with a diffrent title. Confusing.
But here's the reply to that comparing, the way I solved it for a Project Euler exercise:
First of all: the situation is slightly better than you imagine. Since you have two cards in your hand, you have to pick only 3 out of 5 cards, reducing the possibilities from 21 to a mere 10.
Then comparing two hands. What I did to evaluate a hand was to first make a map of your hand. The keys will be the values of the cards (2, 3, 4, ...., K, A), the values of the map will be the corresponding cards.
The valuation is then a two step process.
If the size of the map is 2, then you have either a 4-1 split or a 3-2 aplit. Checking one of the frequencies is rhen sufficient to determine which of the two you have. If the size is 3, then you have two pairs, with a size of 4 you have one pair and a size of 5 will give you the chance of a royal flush.
If that is not sufficient to determine a winner, then make sure that the first key in your map contains the highest value. You can then compare the first key of one hand to the first key of the second. Et cetera. It may boil down to effectively determine the hands card by card.
If you make sure your map is ordered handily, so highest key first, and the values in order of highest colour first, then the comparison is not too hard.
There are three kinds of actuaries: those who can count, and those who can't.