Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When you were little, you probably played a memory matching game where you had to find two cards that match among a set of

 


When you were little, you probably played a memory matching game where you had to find two cards that match among a set of cards which are mixed up and laid out in a grid. You get to reveal cards two at a time, and the cards are hidden again if they don't match. You keep searching for the matching pairs until all the identical pairs are revealed. Write a Java program to simulate a memory matching game. The user will get to set the size of the board at run-time. The board must be square so the number of rows will equal the number of columns. The size of the board must also be an even number so there are an even number of cards to allow for the matching pairs. The cards in the board will have values of 1 up to one half the number of cards on the board. The largest size board supported by the game is a 14 x 14 game board. You must use a 2D array to hold your game board. For example, if the user picks a board size of 4, the board will be a 4 x 4 matrix holding 16 cards. The cards in the board will have values of 1 to 8 with two of each value card placed on the board. Until a matching pair is found, an* will represent the card on your board. Here is an example of a 4x4 board during game play: 1 2 3 4 1 1 2 | 3 | 4 | * * 1 * The cards should be dealt randomly to create the board at the beginning of play. For each turn, the user should be asked to pick two cards to turn over based on the column and row numbers shown for the board. If the two cards match, the values of the matching pair of cards should permanently show in the proper place on the board. If the two cards don't match, the user should be told the value of the cards they revealed in the order they picked the cards, and the should remain when the board is redisplayed for the next turn. At the end of the game, the user should be able to play again or quit.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

import javautil public class MemoryMatchingGame public static void mainString args Scanner scanner n... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Accounting

Authors: Gail Fayerman

1st Canadian Edition

9781118774113, 1118774116, 111803791X, 978-1118037911

More Books

Students also viewed these Programming questions