The Concentration Game
Lab Objective: Build simple user interfaces in Java and implement event handlers, and basic object-oriented design
In this lab you will develop a version of the game commonly known as "concentration". The game involves a small number, say 6, of card pairs. The cards in a pair are identical. For this game, both cards in a pair have the same unique face color, one of red, yellow, green, blue, magenta, or orange. No two pairs of cards share the same face color. The back of each card is gray. All the cards are initially face down, arranged in some random order. Clicking on a card turns it over. If the card revealed is identical to the previous card that was revealed, then both cards remain face up. Otherwise, both are returned face down. The game ends when all cards are face up. Your program should count the number of cards clicked by the user and print out this count to the console when all the card pairs have been identified.
Steps in the solution process:
- What are the components that need to be modeled in this game?
- For each component
- What are its properties?
- What behaviors does it support?
- With which other components does it interact or collaborate?
- Implement each component.
Add a MENU with the options Game(New, Exit) to your program. Choosing Game/New turns all the cards face down and rearranges the cards on the game board. Choosing Game/Exit does the obvious.. Here is an example that illustrates the use of menus.
Here are skeletal implementations of GameCard and GameBoard for you to complete.
Note: Your code must conform to the following coding conventions,