Modify the program you submitted for HW4 in the following
- Your program must prompt the
user for the names of the 4 players, and display the names of the players
above the corresponding columns.
- Eliminate the potential of
dealing the same card more than once.
SAMPLE RUN (user input is in bold italics):
Please enter the name of Player #1: Mauro
Please enter the name of Player #2: Howard
Please enter the name of Player #3: Frank
Please enter the name of Player #4: Jim
Mauro Howard Frank Jim
5 of Diamonds A of Clubs K of Spades 10 of Diamonds
10 of Spades 9 of Diamonds J of Diamonds 7 of Diamonds
J of Clubs 10 of Clubs 7 of Spades 5 of Clubs
Q of Hearts 3 of Diamonds A of Hearts 3 of Hearts
9 of Spades K of Diamonds 4 of Spades K of Hearts
- Use an array to keep track of
each card that is dealt to a player. You will need a boolean array of size 52 in order to do
this. Initially, each element
in the array should be initialized to false. As each card in the deck is dealt, an element
corresponding to that card will be changed to true.
- A good way to map the array
elements to the deck is to use integer division and modulus with your
random number (range 0 – 51).
What numbers would work well?
Hint: There are 13
cards and 4 suits.
- Before printing each card
randomly drawn from the deck, your program must first check the array to
see if the card has already been dealt. If the card was not previously
dealt to a player, your program must display the card and then modify the
array to mark the card as being dealt. If the card was already dealt, then
your program must pick a new card.
- Your program MUST also
prompt the user for the names of the 4 players, and display the names of
the players above the corresponding columns.