예제 #1
0
 public int getHandValue() {
   int total = 0;
   int aces = 0;
   for (Card c : hand) {
     if (c.getFace().equals("Ace")) {
       aces++;
     } else {
       total += c.getValue();
     }
   }
   // evaluate the aces at the end to ensure no errors
   for (int i = 0; i < aces; i++) {
     // Ternary operations!
     total += ((total + 11 <= 21) ? 11 : 1);
   }
   return total;
 }
예제 #2
0
 public void showHand() {
   for (Card c : hand) {
     System.out.println(c.toString());
   }
 }