Program #4 (30 Points)

Program #4 (30 points)

Due: Monday, December 5

Write a program that plays a simple card game with its user, always allowing for the option of playing again. The choice of the card game is up to you; some possible, fairly easy to simulate games include Blackjack, War, or Go Fish. Whatever game you choose should be playable by two players: the user and the computer. You may want to consult a book of game rules (such as Hoyle's) to make sure you know how your game is played. You can simplify the rules somewhat, but if you do, you need to document whatever changes you have made.

Required elements:

·  A method that explains how to play the game; this method should be called if the user asks for help

·  A class that can be used to represent a single card

·  An array of 52 unique card values, representing values of ace through king for each of suits hearts, spades, diamonds and clubs. You may use a smaller array if your game involves less cards (for example, the Hungarian card game duroc involves only the cards from 7 through king).

·  A method that populates your card array, ensuring there are no duplicate values (for example, two aces of hearts).

·  A method that deals a single card from the deck

·  A method that prints out a card value

·  Other methods as necessary to play a game, keep score, report results, etc. You should allow for the possibility of running out of cards (and so the need to replenish the deck)

·  Your program must keep the user informed of his/her progress throughout the game. At minimum, the user should know what cards s/he holds, whose turn it is, and what the result of each turn was. The program should announce when either player wins, and should allow the user the option to play again. If the user does choose to play again, s/he should get a new deck to play with.

Extra credit option (worth up to 15 points)

·  Include a graphical user interface that displays the cards as they are played and any other visual enhancements you wish to include. If you choose to implement this option, you should include buttons, menus, etc. to control various game options. Both the Sun Java tutorial (see the "useful links" page) and chapter 14 of your textbook provide good introductions to GUI programming.

Computer Science I Fall 2005

Sheller Page 1

cs1f05prog4(cards) -- work