Course: Introduction to Computers & Programming (JAVA), Summer 2009
Instructor: Christopher Conway

Homework #5

Due: Thursday, 18 June 2009 at 11:59 PM

In this assignment, you will use a random number generator, loops, and methods that you define to simulate a poker hand between four players.

Play proceeds as follows: four players are dealt 5 cards each from a standard 52-card deck. The cards are dealt around the table to each player in turn, with Player #1 getting the 1st card, Player #2 getting the 2nd card, Player #3 getting the 3rd card, Player #4 getting the 4th card, Player #1 getting the 5th card, and so on, until a total of 20 cards are dealt.

Example run:

Player 1        Player 2        Player 3        Player 4
 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     J 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


Extra Credit (5 points):

Design your program so that it calls Math.random only once for each card. If you choose to do it this way, use Math.random() to generate a number from 0 to 51. Then use the division and modulus operators to map each integer in that range to a card in the deck. You MUST make sure each of the 52 numbers in that range correspond to a unique card.

Style counts:

Your assignment should be submitted BY EMAIL to our class grader: Andrew Lott, adl316 (AT) nyu (DOT) edu.

Last modified: 15 Jun 2009