I have been searching for a while but cant find any answer that matches my problem.
I have 2 Enums
, one with cardvalues
and one with Suits. Since I am trying to create a BlackJack game I would like to have Jack
,Queen
and King
equal to 10
.
Right now Jacks
,Queens
and Kings
point to 10 when using them in my game.
I have also tried Jack=10
, Queen=10
, King=10
but when doing this J
,Q
,K
appears as 10 which creates multiple 10s. I've checked, and either way the deck contains 52 cards.
Could someone tell me whats going one? Thanks in advance!
public enum Value
{
Ace=1,
Two=2,
Three=3,
Four=4,
Five=5,
Six=6,
Seven=7,
Eight=8,
Nine=9,
Ten=10,
Jack=Ten,
Queen=Ten,
King=Ten
}
public enum Suits
{
Hearts,
Clubs,
Spades,
Diamonds
}
public Deck()
{
rand = new Random();
cardlist = new List<Card>();
foreach (Suits s in Enum.GetValues(typeof(Suits)))
{
foreach (Value v in Enum.GetValues(typeof(Value)))
{
cardlist.Add(new Card(s, v));
}
}
ShuffleCards();
}
Did something like this, but still no effect...
public class Card
{
/// <summary>
/// Variables
/// Card has one value and one suit
/// </summary>
Value v;
Suits s;
/// <summary>
/// Constructor
/// </summary>
/// <param name="siu"></param>
/// <param name="val"></param>
public Card ( Suits siu, string val )
{
Value = (Value)Enum.Parse(typeof(Value), val);
Suits = siu;
}
/// <summary>
/// Property value
/// </summary>
public Value Value
{
get { return v;}
set { v = value; }
}
/// <summary>
/// Property Suit
/// </summary>
public Suits Suits
{
get { return s; }
set { s = value; }
}
/// <summary>
/// To string method. Adding value and suit.
/// </summary>
/// <returns></returns>
public override String ToString()
{
return Value.ToString() + " " + Suits.ToString();
}
}