user profile photo
Get it free on Google Play Open in app
Write a Java program
Details
Bids
Management
PROJECT BUDGET (USD)
$ 30 - 250
AVERAGE BID (USD)
$ 307
BIDS
5
PROJECT STATUS
Open : 6d 23h 52m 31s
Upgrade this project
Post a similar project
PROJECT DESCRIPTION
You will implement a game of Memory using 40 cards. Each card will contain a value corresponding to
an uppercase letter, between A and T. Each different letter will be used in exactly two cards. The cards
will be presented to the user in a text console in 5 rows of 8 cards each. For each card, you will use the
letter of the card if it is visible, or an asterisk (*) if it is not. There will be a single space between cards,
and a single line break between lines.
At the start of the game, all cards will be shuffled into a random order, and hidden, and a new round will
start. At the start of each round, the cards will be presented. After a line break, a prompt will be presented
asking for “Select a card:”, and the application will read a position from the terminal. After reading the
position, the corresponding card will be made visible, and the cards will be again presented to the user.
Another prompt will be shown with the text “Select another card:”, and another position will be read from the terminal. Again the corresponding card will be made visible, and the cards will again be
presented to the user.
The user must provide the position of the selected card using a two-digit number. The first digit will
correspond to the row, while the second digit will correspond to the column, with rows and columns
being counted from zero (e.g., 00 is the card in the first row and first column, while 47 is the card in the
last row and last column).
After both cards are shown to the user, the program will compare their values. If the values are the same,
both cards are removed from the table. If they are different, they are again marked as hidden. In either
case, no card should move positions. Any position where a card was removed will be replaced with a
space to indicate that there is no card in that position. There is no reshuffling at any point. After this takes
place, a new round starts, and the cards are presented again to the user. After all cards are removed from
the table, your program should close.
Note that, since the console will present the new cards just below the previous round, the user will still
be able to see the cards that were supposed to be hidden. This is perfectly acceptable for this assignment.
OPTIONAL: If you wish to do any extra processing at this case, you are welcome to do so, but note that
it will not incur in any additional marks. One suggestion in this scenario is to print a long series of empty
lines. If you do so, though, make sure to give the user enough time to see the second selected card before
cleaning the table. You can do so by calling “[login to view URL](2000);”, replacing 2000 with an appropriate
number of milliseconds to wait.
When reading a position from the terminal, you must check if the position is valid. Validity in this case
includes checking if the position has the correct length, contains only valid digits, contains digits that are
within the boundaries of the number of rows and columns, and that the position still has a card (no card
was removed from that position). If the position is invalid, you must print an appropriate message
explaining why the position is invalid, and ask for a new position. You must repeat the validity check for
all positions you read.
You must accept a number
between 1 and 8, and reject any invalid input. After reading the number of players, you will read the
name of each player, which can be any valid string. Each player will also be initialized with a score of
zero. A random player will be assigned to be the first to play.
Once the player names are read, the game starts as in part 1. However, before reading the first position
of a round, you must print the name of the player that is in turn. After the round is complete, if the cards
have the same value, the player currently in turn will have its score incremented by 1 (one). The current
player continues to be in turn. If the cards have different values, the next player in the list (or the first
player, if the last player in the list is in turn) will receive the [login to view URL] the end of the game, after all cards are removed from the table, the application will print the names of
all players and their corresponding scores. The format of the scores is open, as long as it is clear. You are
free to print the player names in the order they were inputted or in decreasing order of score