QUOTE(c#newbiefc @ 11 Apr, 2008 - 09:27 AM)

hi. im trying to design a poker game as a windows application.i have managed to dealcards and now trying to score each players hand.
i have tried using a string array for the 7 cards(2 player cards,5 community cards) but im getting a little stuck.
ie playerhand[7]={10h,10s,7c,ad,ah,ks,3c},
i am trying to find a way of extracting cards with same value(ie 10h,10s) to
determine whether player has a pair (or 2pair,3 of akind,4 of a kind etc.)
can anybody point me in the right direction here?
Okay.
I am assuming your array is a bunch of strings. This might make what you are trying to do a little difficult.
I dont know specifically how you are doing this, but I might suggest going back and designing your application a little differently.
I would make a card class, with properties "Value" and "Suit". Then create a global enumerator (http://msdn2.microsoft.com/en-us/library/sbbt4032(VS.80).aspx) for the different values (Ace through King) and a global enumerator of the suit (Clubs, Hearts, Spades, Diamonds). This way it will be easier to compare what your hand is.
If you really want to get fancy, you could create a comparable interface that would allow you to simply input two different "hands" (another class you might consider making) and see which is higher. Here is potentially some demo code.
I wrote this in like....5 minutes. But I hope it gives you an idea of where you may start. I also suggested making a "Hand" class for each player...
CODE
using System;
public enum Value
{
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Jack,
Queen,
King,
Ace
}
public enum Suit
{
Hearts,
Clubs,
Diamonds,
Spades
}
public class Card
{
Suit type;
Value cardValue;
public Card(Value newCardValue, Suit newCardSuit)
{
cardValue = newCardValue;
cardSuit = newCardSuit;
}
public Suit cardSuit
{
get { return type; }
set { this.type = value; }
}
public Value cardValue
{
get { return cardValue; }
set { this.cardValue = value; }
}
}