In making a card game I came to a Straight, the numbers were set as an enum ace, two, three etc. and I wrote it like this
List number = Arrays.asList(Number.two, Number.two, Number.three, Number.four, Number.five);
private void Straight() { for(int currentCard = 0; currentCard < 4; currentCard++){ for(int searchCard = 0; searchCard < 4; searchCard++){ if (number.get(searchCard) == number.get(currentCard ++)){ if (number.get(searchCard ++) == number.get(currentCard + 2)){ if (number.get(searchCard + 2) == number.get(currentCard + 3)){ } } } }
Looking at this I see currentCard will loop through the hand and not the enum set like I would like it to do. Which way would be most efficient to do this