Alright, I have to write a program that parses playing cards from a file into 2 5-card poker hands, and determine which hand is better, and what it contains (flush, pairs, straight, etc). My original plan was to have a Hand class and a Card class. The card class was going to have a constructor that looked like Card(int rank, Suit suit), where suit was an enumerated type probably. Then the Hand class would be Hand(Card c1, Card c2, Card c3, Card c4, Card c5). Then, I could instantiate 2 Hand objects and invoke methods such as: Hand sort(), bool getPairs(), bool getStraight(). However, my problem is getting the classes started right, I'm not sure how to setup the classes so that it would let me setup hands like that. For example, this is how I wanted to set it up, but it doesn't like how I do this, any advice?
CODE
public class Card {
Card(int the_rank, Suit the_suit)
{
rank = the_rank;
suit = the_suit;
}
public enum Suit {CLUBS, HEARTS, SPADES, DIAMONDS }
Suit suit;
int rank;
}
public class Hand {
Hand(Card first, Card second, Card third, Card fourth, Card fifth)
{
card1=first;
card2=second;
card3=third;
card4=fourth;
card5=fifth;
}
public static void main(String[] args)
{
Card card1=new Card(5, DIAMONDS);
}
Card card1, card2, card3, card4, card5;
}