i'm having a bit of trouble on the last bit of my program. I'm not too sure how to calculate int's within my array. Here's my code so far:
class Tester
{
static void Main(string[] args)
{
Card[] hand = {
new Card("Spade", 3),
new Card("Club", 10),
new Card("Diamond", 11),
new Card("Heart", 9),
new Card("Diamond", 13),
};
ProcessHand(hand);
}//end of static void main
static void ProcessHand(Card[] cards)
{
cards[0].DisplayCard();
cards[1].DisplayCard();
cards[2].DisplayCard();
cards[3].DisplayCard();
cards[4].DisplayCard();
}//end of static void processhand
}//end of class Tester
class Card
{
public string suit { get; set; }
public int facevalue { get; set; }
public Card (string su, int fa)
{
suit = su;
facevalue = fa;
}
public int Sum(params int[] facevalue)// <- trying to calculate sum of facevalues of cards.
{
return facevalue.Sum();
}
public void DisplayCard()
{
Console.WriteLine("The card is {0,-10} {1,-10}", suit, facevalue);
}
}//end of class Card
I'm a bit confused on where to firstly put the code, as i'm trying to put it in the class Card. I've tried different variants of everything i know, within both classes but nothing seems to work. I'm simply wanting to sum all the facevalues of the cards shown at the top, and then use console.writeline to show the total value.
Any help would be appreciated! thanks :)