
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Notes; Class: Programming Lab; Subject: Computer Science; University: Loyola Marymount University; Term: Spring 2008;
Typology: Study notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!
Spring 2008
For our first problem, we’ll revisit some code that you wrote in CMSI 185 — the poker hand classifier. You will build upon this code to write a text-based video poker program.
Write a set of Java classes that includes a poker.VideoPoker class. When invoked via java poker.VideoPoker , this program creates a deck of cards, shuffles it, then displays the top five cards of the deck to the user. Each card should be num- bered from card 1 to card 5. The program then asks the user to enter the cards that he or she would like to hold. The user is ex- pected to enter these cards as a comma-separated list of numbers, such as “2, 3, 5.” The program should be robust enough, however, to reject any other user input without terminating in an error. Incorrectly formatted input should be met with an error message and an offer to try again. If the user enters nothing, then this is interpreted as “hold none of the cards.” The program then replaces the cards that were not held with the next cards on the deck. The final set of five cards is displayed, and the program states the poker hand that was formed, if any.
You will need at least three other classes in addition to poker.VideoPoker :
- poker.Card^ represents a single playing card, with methods for determining that card’s suit and rank, as well as representing that card as a human-readable string - poker.Deck^ represents a standard set of 52 playing cards, with methods for accessing individual cards in that deck as well as shuffling the deck and checking it for validity - poker.PokerHandClassifier^ holds^ routines^ for^ de- termining whether a set of cards contains a known poker hand And, because PokerHandClassifier can be somewhat involved, you should have a PokerHandClassifierTest class as well.
After you have fulfilled the core specifications of the video poker program, you can explore the fol- lowing enhancements:
- Add a command line argument which specifies number of hands that the user wishes to play. For example, invoking: java poker.VideoPoker 5 …should play 5 hands of video poker. - Implement a scoring system; attaining the better (and rarer) poker hands results in more points and thus higher scores. - Improve the user interface; in a text-based envi- ronment, can the program interact with the user in a manner that is easier to learn, more enter- taining, and/or less prone to errors? - The Java^ enum^ construct is a (relatively) new addi- tion to the language. Look it up and see if you can use it to improve your code in some way.