I am supposed to do a project where I declare and instantiate 5 empty card slots called myHand using arrays, and I will need an advanced mutator method that sets a single card into the hand, and an advanced accessor that gets a card from myHand. Does the following code work for all of above? Please know that Card is from another class called Card.java where all card values, suits, etc. are completed
private Card[] myHand;
private int numberHand; //counts number of card in hand
private int numberDealt; //counts number of cards dealt onto the table
public void setCard(int I, Card c)
{
myHand[I]=c;
numberHand++;
}
public Card getCard()
{
Card tempCard = myHand[numberDealt];
numberDealt++;
return tempCard;
}