96.8k views
5 votes
In this assignment we will work on the creation of a poker game. at a minimum your game must deal 2 hands of cards, and print out what poker hand each has. it must also determine which hand has won the game – but breaking a tie will be for bonus points. for example, if both hands have 3 of a kind, that can be considered a tie. if you want the bonus points write some code that determines which 3 of a kind is higher. here is the output from dealing a hand of cards: ace of hearts ten of clubs ace of clubs eight of hearts seven of diamonds 2 2 1 0 <> 0 0 0 0 0 1 1 0 1 0 0 0 2 you have a pair!

User Johnwargo
by
8.0k points

1 Answer

2 votes
Since the programming language for this program is not specified, here's a simple JAVA program for you:

public class Card //Name of your program
{
private short rank, suit;
private static String[] suits = { "hearts", "spades", "diamonds", "clubs" };
private static String[] ranks = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" };
public static String rankAsString( int __rank ) { return ranks[__rank];
}
Card(short suit, short rank)
{
this.rank=rank; this.suit=suit;
}
public @Override String toString()
{
return ranks[rank] + " of " + suits[suit];
}
public short getRank()
{
return rank;
}
public short getSuit()
{
return suit;
}
}//End of program
User Carbocation
by
8.1k points