I'm a begginer in java. and I'm doing a Matching/Memory Game in JCreator using buttons and if-else statements.
It's just the typical Matching/Memory Game. When you click the buttons, the image clicked will pop up then if you click the next one, but it's not the same image, then both will close. If you get the correct matching image, they both disable. My problem is the logic of matching it.
What will I do or use to make my program know that two buttons match?
I hope someone is getting what i mean here :(
This is how it looks when the buttons are clicked. New game button is working too. It reverts back to the closed buttons.
I really need help with this asap! This is my assignment, to be passed this tuesday.
I'll be really grateful if someone could help me!
Re: Matching Game
One way to get this to work is to use ImageIcons. Note that two buttons can share the same ImageIcon, and so you could distribute 8 pairs of ImageIcons to the 16 buttons, and then compare ImageIcons with the equals(...) method.
Myself when I've done this, I've separated the game logic from the GUI, and created a "model" with buttons, that could be compared to see if they were equal, but this is not necessary if you're creating this game.