title: Java blackjack program
body: <p><strong>So I rewrote it with your suggestion (Todd Hopp) and updated the post in the (*) section in the BlackJack class so you can see how I have it now but I'm still getting the same errors and it is not printing the computePlayerValue for some reason....</strong></p>
  
  <hr>
  
  <p>ERROR: 
      Exception in thread "main" java.lang.NumberFormatException: For input  string: "King"           at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)    </p>
  
  <pre><code>at java.lang.Integer.parseInt(Integer.java:580)
  at java.lang.Integer.parseInt(Integer.java:615)
  at BlackJack.dealCards(BlackJack.java:25)
  at PlayCardGame.main(PlayCardGame.java:9)
  </code></pre>
  
  <p><strong>P.S. I'm was trying to look this up in the book but couldn't find the answer...The BlackJack class is partially source code from an earlier chapter in the book and I couldn't figure out if it was necessary to have super(); in the constructor there?  I thought it only had to do if the parent class constructor had an argument?  Any help on if it has to be there and if so what it's doing.</strong>  </p>
  
  <p>BlackJack Class</p>
  
  <pre><code> public class BlackJack extends CardGameFP{
      int computePlayerValue;
      int computeDealerValue;
      int cardValue;
  
      public BlackJack() {
          **super();**
          player1 = 2;
          player2 = 2;
      }
  
      public void display() {
          System.out.println("BlackJack");
      }
  //************************************************************* 
      public int getCardValue(Card card) {
      final String rank = card.getRank();
      switch (rank) {
          case "Ace":
              return 1;
          case "King":
          case "Queen":
          case "Jack":
              return 10;
          default:
              return Integer.parseInt(rank);
      }
  }
  
  public void dealCards() {
      //Player 1
      System.out.println("Player 1:");
      for(int x = 0; x &lt; playerHand; x++) {
          shuffle();
          System.out.println(fullDeck[x].getRank() + " of " + fullDeck[x].getSuit());
      }
      cardValue1 = getCardValue(fullDeck[0]);
      cardValue2 = getCardValue(fullDeck[1]);
      computePlayerValue = cardValue1 + cardValue2;
      System.out.println(computePlayerValue);
  }
  
  //*************************************************************
  
  
          //Dealer hand
          System.out.println("\nPlayer 2:");
          for(int x = 0; x &lt; player2; x++) {
              System.out.println(fullDeck[x].getRank() + " of " + fullDeck[x].getSuit() );
              shuffle();
          }
      }
      }
  
  
  public class Card {
  
  protected String suit;
  protected int value;
  protected String rank;
  protected final int LOW_VALUE = 1;
  protected final int HIGH_VALUE = 13;
  
  
  public String getRank() {
      return rank;
  }
  
  public int getValue() {
      return value;
  }
  
  public String getSuit() { 
      return suit;
  }
  
  public void setSuit(String st) {
      suit = st;
  }
  
  public void setValue(int val) {
      if(val &gt;= LOW_VALUE &amp;&amp; val &lt;= HIGH_VALUE) {
          value = val;
      }
      else {
          value = LOW_VALUE;
      }
      if(val == 1) {
          rank = "Ace";
      }
      else if(val == 11) {
          rank = "Jack";
      }
      else if(val == 12) {
          rank = "Queen";
      }
      else if(val == 13) {
          rank = "King";
      }
      else {
          rank = Integer.toString(value);
      }           
  }   
  }
  </code></pre>
  
  <p>CardGame Class</p>
  
  <pre><code>abstract public class CardGameFP {
  
  int suitNum = 1;
  int val = 1;
  int player1;
  int player2;
  protected final int DECK_OF_CARDS = 52;
  Card fullDeck[] = new Card[DECK_OF_CARDS];
  protected final int LOW_VALUE = 1;
  protected final int HIGH_VALUE = 13;
  protected final int HIGH_SUIT = 4;
  protected final int CARDS_IN_SUIT = 13;
  
  public abstract void display();
  public abstract void dealCards();
  
  public CardGameFP() {
      for(int i = 0; i &lt; fullDeck.length; i++) {
          fullDeck[i] = new Card();
          if(suitNum == 1) {
              fullDeck[i].setSuit("Spades");
          }
          else if(suitNum == 2) {
              fullDeck[i].setSuit("Hearts");
          }
          else if(suitNum == 3) {
              fullDeck[i].setSuit("Diamonds");
          }
          else {
              fullDeck[i].setSuit("Clubs");
          }
          fullDeck[i].setValue(val);
          val++;
          if(val &gt; HIGH_VALUE) {
              suitNum++;
              val = 1;
          }            
      }//end for
  }   
  public void shuffle() {
      for(int firstCard = 0; firstCard &lt; DECK_OF_CARDS; firstCard++ ) {
          firstCard = ((int)(Math.random() * 500) % DECK_OF_CARDS);
          int secondCard = ((int)(Math.random() * 500) % DECK_OF_CARDS);
          Card temp = fullDeck[firstCard];
          fullDeck[firstCard] = fullDeck[secondCard];
          fullDeck[secondCard] = temp;
      }
  }
  }
  </code></pre>
  
  <p>PlayCardGame Class</p>
  
  <pre><code>PlayerCardGame
  
      public class PlayCardGame {
  
      public static void main(String[] args) {
          Card CG = new Card();
          BlackJack BJ = new BlackJack();
  
          BJ.display();
          BJ.dealCards();
      }
      }
  </code></pre>