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.
Might mean that there are not enough cards to make a
hand - possibly because there are 52
cards in a deck and you say
below that the cards are coming from a single deck -- NOT WHAT WAS INTENDED
WE ARE NOT GOING THROUGH AN ENTIRE DECK – THE USER IS ENTERING ANY 5
CARDS AS LONG AS
NO TWO IN THE SAME HAND ARE IDENTICAL
Might mean that user isn’t entering any more data
How does the program know that the user
isn’t entering any more data?
The language might provide the ability to detect an end of
file -- (if the user enters <ctrl> z ) from the keyboard it signals
an end of file –
if the program is reading from a file, it would be detected.
It might crash because it tries to read and there’s no
data - you
could use an exception handler to avoid the crash
What exception handler could you use?
You could use
others. \
Is using others a good idea?
Only while you are testing the program only
to see if it handles end of data situation.
Not a good idea in general because you might have a
different kind of error occurring which would require a different action
Good idea to figure out which
exception end of data is…
Can not ask the user how many hands they want to have evaluated?
There will be no more than 10 hands but there may be less..
Why might I tell you
that there will be no more than 10 hands?
Not bcause there are only
52 cards in a single deck – that’s irrelevant in this problem
In case someone wanted to create an array of hands.
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..
How does the user know what to enter?
You tell them.
What do you tell them?
Set of legal values to enter
What does the rank look like?
It can’t be a number because it has
to be an enumerated type and Ada doesn’t allow numbers in enumerated types
It shouldn’t be a character
It shouldn’t be a string
Five or six or seven or jack or
queen
Type rank has been declared,
ace is high,
Package rank_io is new
ada.text_io.enumeration_io (rank);
After each set of 5 cards is entered, the program
should echo the cards and describe the hand.
You do not have to worry about incomplete
hands. You just need to handle no more
data.
You may assume that the cards are coming from a single legal deck. ( 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 ace two three four
five does not have to be considered a straight
A flush
A straight flush
In poker we don’t care if a hand has a pair and a hand has four of a kind, we only care that the hand has 4 of a kind – i.e. we are interested in the best hand that can be made from the five cards not all possible hands.
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.
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.