CPSC 120 Assignment #4 Five-card Draw Friday December 4, 2009 by 4 p.m.

In this assignment you will write a program that plays a variation of the poker game called five-card draw. The main idea of five-card draw is to get a hand of five cards with the highest rank. We will use the following ranks (from highest to lowest):

• Four of a Kind: four cards of the same rank
• Full House: five cards of two ranks
• Flush: five cards of the same suit
• Three of a Kind: three cards of the same rank
• Two Pairs: four cards of two ranks
• One Pair: two cards of the same rank
• Nothing: none of the above

The game proceeds as follows:

• Each player is dealt five cards from a deck.
• Each player is allowed to swap up to two cards for new cards from the deck.
• The player that has the highest rank wins.
• If multiple players have the same rank, then the player with the hand that contains the largest sum of card ranks wins.
• If multiple players have the same rank and sum, then it is a tie.

Your program will play the game between a human player and a dealer. It should ask for the name of the player, then have a loop that lets the player keep playing games against the dealer. It should clearly indicate what is happening as the game is played. The player should go first. When it is the dealer's turn if the dealer's rank is nothing, it should swap the two lowest valued cards.

Sample output:

```     Welcome to the Casino!
========================

Please enter the player's name: Bozo

Dealing Bozo's hand...
Bozo's cards are: 3♦ A♥ 8♣ 5♠ Q♥

Dealing Dealer's hand...

Bozo's turn...
Please enter the number of cards to exchange (0 - 2): 2
Please enter the index of a card to exchange (0 - 4): 0
Please enter the index of a card to exchange (0 - 4): 3

Bozo's cards are: 10♣ A♥ 8♣ A♠ Q♥

Dealer's turn...
Dealer's cards are: 2♥ 3♣ K♣ J♦ 8♠

Dealer exchanges 2 cards...
Dealer's cards are: 8♦ 9♥ K♣ J♦ 8♠

Bozo wins!

Please enter y to play again: n

```

• Follow the class specifications document that we discussed in class.
• Use the PokerTest.java program (or a similar program you write) to test your classes as you develop them. Note, you should add additional tests to this program to verify that all methods work properly before beginning to write your poker playing program.
• All user input should be verified using a loop. For example, it should not be possible for the user to choose to exchange 3 cards.
• Use good programming style -- meaningful variable names, named constants, use of white space, proper indentation.
• Document your program. Each class must have header documentation at the top that includes a description of the purpose of the program or class (for a class it should be what "objects" it represents) and your name. Each method must have documentation that includes the clear description of the purpose of the method, a description of each parameter, and a description of what is returned by the method (if it is not void). Have internal documentation where necessary that delineates and succinctly (and clearly) indicates what each section is doing.

Grading Your program will be graded both on style and correctness. Style includes adherence to rules for naming of identifiers and use of white space; it also includes coding style such as the absence of unnecessary code (extra comparisons in if's or extra assignments); it includes good class design (appropriate choice of instance variables and methods); it includes appropriate documentation. Style will be 20% of the grade on the assignment. Correctness includes meeting all the specifications of the assignment. A program that does not compile has an automatic deduction of 70% no matter how "close" it is to compiling or running. Come see me if you have problems with the assignment. It is important that you get in the habit of producing correct programs!

Academic Integrity Reminder!!! Programming assignments are to be your own work. You may get help on the specifics of the assignment from no one except the instructor. You may not show your program to anyone or look at anyone else's program or share ideas with anyone about how to write the program.

Submission: cp a tgz file (with your name as the file name) that contains the java files for your program to the directory:

```   /home/staff/bouchard/CPSC120B/assign4
```