This program is not due until Thursday the 28th.
However, you may run into some problems so you should do a bit of work before Tuesday’s class so you can get clarification on things that aren’t working the way you expected them to.
Write an Ada program will evaluate poker hands until there are no more hands to evaluate.
You are not
being asked to play celebrity poker.
That means: program shouldn’t
handle a single hand and quit
It does not mean you should specify what the user should enter to
indicate that there are no more hands
The program should detect an end of file
What if you’re not using
files, how does the program detect an end of file? User enters <ctrl>z
How does the program
detect end of file?
It
can try and read data that doesn’t exist which will raise an exception – (you
should figure out which one)
Using others to catch all exceptions doesn’t work well because program should quit gracefully when
it's out of data but should prompt the user to try again when they put in clover for clubs or hearts for rank
YOUR
PROGRAM SHOULD NOT QUIT ON CLOVER – EVEN WITH A FRIENDLY MESSAGE
You can look in the LRM under end_of_file
and end_error and see if there’s another way
There will be no more than 10 hands but there may be less..
WHY AM I TELING YOU THAT YOU WON’T HAVE MORE THAN 10 HANDS
These cards are coming from the user not a single deck is not
the reason
It’s so that if you want to hold onto all of the user’s input
data throughout the program, you will know how big your data structure
needs
to be
A hand consists of 5 cards that are to be entered 1 at a time.
Your program should expect the user to enter a rank and a suit for each card..
In a bust hand with
nothing the high card determines the
winner if everyone stands – so the ace should but after the king not
before two.
Suits should be
clubs, diamonds, hearts, spades
These are not strings, they are enumerated type values.
What happens if my enumerated values are heart, spade (i.e.
not plural)?
The user should be prompted by being shown legal
values –
In what order should they be
entered (i.e. rank first or suit first)
- not sure I care but they should be entered in response
to a prompt
After each set of 5 cards is entered, the program should echo the cards and describe the hand.
You may assume that the cards are coming from a single legal deck per hand
( i.e. it is illegal for there to be two identical cards in a given hand)
Possible hands are:
A bust (none of the hands that follow)
One pair
Two pair
Three of a kind
A full house (three of one kind, two of another)
Four of a kind
A straight
A flush
A straight flush
If a given hand would fall into multiple of the above categories, do we have to tell them all? NO – we are interested in the BEST hand that can be made of the 5 cards
REQUIRED elements
You must call your main procedure (the executable) Poker.
You must use enumerated types for the rank and the suit of each card.
NUMBERS (I.E. 2, 3) ARE NOT ALLOWED IN ENUMERATED TYPES
You must use a record to hold the rank and suit associated with a card.
You must use an array to hold the cards belonging to a given hand.
You must use a case statement AND/OR an if … then … else AND/OR an if … then …elsif control structure
You must include exception handling for errors the user could make.
Possible errors include but are not limited to:
Incorrect input of suit name (i.e. spider instead of spade)
Duplicate card being entered
File not found (if files are used for input)
You must include the standard heading and descriptions of program purpose, input and output.
You must also include comments telling
a. what your code is doing
b. something about the way the Ada language is doing it.
Your program should tell the user what it will do and what input it expects.
Output should be labeled.
Optional elements
You may make use of a separate package of specifications
You may make use of a separate package body to evaluate the hands.
You may make each of your procedures a separate file and have your main procedure with each of them (this allows for easy separate compilation for syntax ) OR you may embed your procedures in the file with your main procedure.
You may use files to obtain your input but you need to allow the user to provide the name and path of the file to be used (see file usage in Eight Queens)
You may send your results to a file but again you need to allow the user to provide the name and path of the file to be used if your program does this.