C#: What is the preferred way to handle this error?
Posted
by
Ash
on Stack Overflow
See other posts from Stack Overflow
or by Ash
Published on 2011-01-04T23:33:16Z
Indexed on
2011/01/04
23:53 UTC
Read the original article
Hit count: 310
I have a class 'Hand' that consists of two playing cards as below:
public class Card
{
public char r, s;
public Card(char rank, char suit)
{
r = rank;
s = suit;
}
}
public class Hand
{
public Card c1, c2;
public Hand(Card one, Card two)
{
c1 = one;
c2 = two;
}
}
In a 52 card deck we can't have two identical cards. How should I deal with an error where I accidentally instance a class with two identical cards, e.g (Ah, Ah)?
Thanks, Ash
© Stack Overflow or respective owner