I was wondering if anyone could simply explane how this works. I have these two programs and I am having trouble understanding them. My hand class makes a hand of cards:
//Displays a hand of cards. public void displayHand() { System.out.println(Handofcards); System.out.println(); }
//Takes a card out of the hand, tells you what card was removed, //then prints the hand without the card. public Card disCard(int index) { Card temp=(Card)Handofcards.remove(0); return temp;
}
public void addCard(Card c) { Handofcards.addElement(c);
}
//Displays the number of cards you have in your hand. public int getNumCards() { System.out.println("Number of cards in hand"); return Handofcards.size(); }
}
My blackjack has these two methods that just get the score of the hand.
public class Blackjack extends Hand { //-------------------------------------------------------------------- //Holds the score keeping class for the BlackJack game //-------------------------------------------------------------------- public Blackjack() { super(); }
public int score() { int scoretotal=0; int face=10; int ace=11; for(int count=0;count<Handofcards.size();count++) { Card temp=(Card)Handofcards.elementAt(count); if(temp.value==10) { scoretotal+=face; } else if(temp.value==1) { scoretotal+=ace; } else scoretotal+=temp.value; } return scoretotal; }