I've decided to not just find pairs. I could just use a counter and keep on adding to it until 4 cards with the same value are found. When the card with the same value as the one currently being checked is found, that element is being placed into an Ingeter array. When counter is equal to 4, an if statement will run. Inside that if statement is another for loop (for(int remove=0; remove< ...)etc etc) that will remove the elements in the array from the playerHand as long as int remove is less than the length of the array.
It seems logical but I haven't actually tried to run it yet even though it does build with no problems. I'm just...going to move on to other parts of the program that still needs to be written.
Other Things
I think I'm just missing the part that will determine when the player wins. That would be when the player has 0 cards left in the list which I could use isEmpty...and I should check if the list is empty after each card that is removed from the list. If the player has no cards left then they should be brought back to the main menu after a JOptionPane shows up to tell them so.
And I just realised that I haven't written the code for the computer to ask if the player has certain cards... O_O
No comments:
Post a Comment