Question: Write a program that simulates a deck of cards. There are 52 cards in a deck. A deck consists of four suits (Diamonds, Hearts, Clubs
Write a program that simulates a deck of cards. There are 52 cards in a deck. A deck consists of four suits (Diamonds, Hearts, Clubs and Spades). Each suit contains 13 values (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen and King). The user will indicate how many cards they wish to draw from a deck of cards. Your program will then draw that many cards and then display the suits and values of all the cards drawn. You can assume you are drawing with replacement, which means you put each card back into the deck after drawing it. I'm not understanding how to do this with methods. 1) Create a method that accepts one integer parameter and has a String array (or String[]) return type. The method will randomly draw cards from a simulated deck and add them to a string array that is returned after cards are drawn. 2) Create a method that accepts one String array (or String[]) parameter and has a void return type. The method will perform the System.out.println() function on all elements of the string array. 3) The main method of the program will receive user input and call both methods. a. User input will be the parameter for the method 1 call b. The returned string array from method 1 will be the parameter for the method 2 call 4) You may choose to use either the console or the Java dialog boxes for data input and output. 5) If the number of cards to draw is zero or a negative, your program should report the error and exit the program: you can do this with System.exit(0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
