| using System;
public enum CardSuite:byte
{Spades, Hearts, Clubs, Diamonds };
public enum CardValue: byte
{Ace = 1, Two = 2, Three = 3, Four = 4, Five = 5,
Six = 6, Seven = 7, Eight = 8, Nine = 9, Ten = 10,
Jack = 11, Queen = 12, King = 13};
public struct Card {
private CardSuite suite;
private CardValue value;
public Card(CardSuite suite, CardValue value){
this.suite = suite;
this.value = value;
}
public Card(CardSuite suite, int value){
this.suite = suite;
this.value = (CardValue)value;
}
public CardSuite Suite(){
return this.suite;
}
public CardValue Value (){
return this.value;
}
public System.Drawing.Color Color (){
System.Drawing.Color result;
if (suite == CardSuite.Spades || suite == CardSuite.Clubs)
result = System.Drawing.Color.Black;
else
result = System.Drawing.Color.Red;
return result;
}
public override String ToString(){
return String.Format("Suite:{0}, Value:{1}, Color:{2}",
suite, value, Color().ToString());
}
} |