The best overload for ' ' has some invalid arguments

  • Thread starter Thread starter Josh304
  • Start date Start date
J

Josh304

Guest
I am creating a blackjack game and so far I have made a card class, deck class and shoe class. The card class works the deck class works, the shoe class works but I am still working on my hand class. I created a GetSum method to Return the sum of the cards in the hand by calling the SymbolToValue method to obtain the value for each card symbol and adding the values up. but my SymbolToValue method keeps giving me the error The best overload for BlackJack.Hand.SymbolToValue(string) has some invalid arguments. It also for some reason on my _hand.length says that system.Array does not contain a definition for length I am not sure on how to fix this.

Any help or guidance in the right direction would be appreciated

Heres what I have for my hand class


class Hand
{
const Int32 MAX_CARDS = 12;
private Card[] _hand = new Card[MAX_CARDS];
private Int32 _cardCount;
public Hand()
{
_cardCount = 0;
}
public Int32 CardCount
{
get
{

return _cardCount;
}
}
public void AddCard(Card card)
{

if (_cardCount < MAX_CARDS)
{
throw new Exception("Cannot of more than 12 cards in a hand");
}
else
{
_hand.Add(card);
_cardCount++;


}
}
public Card GetCard(Int32 cardIndex)
{
if (cardIndex >= _cardCount)
{
throw new Exception("Invalid Entry");
}
else
{
return _hand[cardIndex];
}
}
Int32[] cardValues = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10 };
String[] cardSymbols = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
private Int32 SymbolToValue(String symbol)
{
int index = Array.IndexOf(cardSymbols, symbol);
if (index != -1)
{
return cardValues[index];
}
else
{
throw new Exception("Value Not In Table");
}
}
public Int32 GetSum()
{
int value = 0;
Boolean aceflag;
for (int i = 0; i < _hand.length; i++)
{
value += SymbolToValue(_hand);
}

return value;

}
}

Continue reading...
 
Back
Top