Question
JAVA 101: ----Java Card Matching Game---- Directions: Create your matching card game by Welcoming the user to your game, prompt them for their full name
----Java Card Matching Game----
Directions: Create your matching card game by Welcoming the user to your game, prompt them for their full name and wishing them luck based on their first name in all caps. Then have them enter a card value and a card suit. Generate a random card value and suit using the random method. Use an if / else statement to compare the results of both the card value and suit of the users guess to the computer guess for a match. Notify the user if the cards match in value and suit. See key below to guide you
- prompt the user:
first, welcome the user and inform them of the name of the game
have the user enter their full name and then wish them luck with their first name in capital letters
- input from the keyboard:
validate user entered a correct selection value, otherwise, notify the user with descriptive text the entry was incorrect.
- pre-built class methods:
use at least ONE char data type and char method in your program
use at least ONE String type and String method in your program to generate a pseudo-random card for values of 1 13 (A K)
use the following Math.random() method and values to cast and truncate the double return value to a card of an integer value:
int card = (int) (Math.random() * 13 + 1); // using + 1 one avoids rolling zero
- determine ace and face cards
if a card value is a 1, then print Ace in output
if a card value is a 11, 12, or 13 then print Jack, Queen, or King in output
- determine suit
using Math.random() to generate numbers 1 4 for suit and using a Switch statement of if / else to set the suit value in characters or text based int value
Example:
int suit = (int)(Math.random() * 4 + 1);
if(suit == 1)
{
String cardSuit = Hearts;
}
- determine match
determine if the users card number and suit matches the computers number & suit
- escape sequence & display to the user
notify the user of the card guess for the number & suit
notify the user of the computer guess of the card number & suit
notify the user if there is a match or not
in one or more of your output statements use an escape sequence
Example output:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started