I'm trying to create an a blackjack game for my C# class and I've been trying to figure out how to obtain a random suit/card value from reciprocating char arrays. The goal is to return these values to a console application to "test" the return values and see if they're correct/adequate.
I have already declared the fields, properties, and set up a constructor. I just can't figure out how to get the values to return them so that they can be tested. We've just started using these things in my class as well.
[Additional Information added from O.P.'s "answer" below]
Right now, we're just trying to obtain a single card that is translated into a console application and the setup of the arrays is what the teacher told us to use.
public class Card
{
//Declaration of fields
char[] suit = new char[] { 'D', 'H', 'S', 'C' }; //Backing Variables
char[] value = new char[]{'A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K'};
static Random random = new Random();
public Card(char s, char v) //Constructor
{
suit = s;
value = v;
}
public char Suit //Properties
{
int suitType = random.Next(0, suit.Length);
char s = suit[suitType];
get { return value; }
}
public char Value
{
get { return value; }
}
}
cardand an array of 52 of those (for each deck used). They would have properties ofSuitandDisplayCharandValue. My main concern is that randomizing the suit and the value does not guarantee a proper deck. If using two char arrays and one deck's worth of cards, it would be possible to deal four jack of spades cards.