/**
  * Deals a new card onto the board. Removes the card it adds from the pack. Prints all the cards
  * on the board
  */
 private void dealCard() {
   ;
   char aChar = 0;
   char bChar = 0;
   toggleLock = true; // Makes it so you can no longer change if the log is on or off
   if (cardsInDeck > 0) { // Only deals a card if there is a card to deal
     String card = pack.getFirtCard(); // Gets the card on top of the deck
     cardStrings.add(card); // Adds this card to the arraylist that the frame prints from.
     for (String c : cardStrings) { // For all the cards on the table
       aChar = c.charAt(0);
       bChar = c.charAt(1);
       StringBuilder sb = new StringBuilder(3);
       sb.append(aChar).append(bChar).append(" ");
       if (printBoard) {
         System.out.print(sb); // Prints the current board to the command line
       }
     }
     frame.cardDisplay(cardStrings); // Prints the cards to the frame
     System.out.println("");
     Pile pile = new Pile(aChar, bChar); // Creates a new pile of the newly laid card
     piles.addPile(pile); // Adds it to the arrayList of current piles on board
     cardsInDeck--;
     saveLog(); // Calls the function to save the new move to the log
   } else {
     printFrame();
     drawCard = false; // Tells the AI that he cannot draw a card
     System.out.println("No more cards in deck!");
   }
 }
 /** Prints the current state of the board */
 private void printFrame() {
   char aChar = 0;
   char bChar = 0;
   for (String c : cardStrings) { // For all the cards on the table
     aChar = c.charAt(0);
     bChar = c.charAt(1);
     StringBuilder sb = new StringBuilder(3);
     sb.append(aChar).append(bChar).append(" "); // Create a string of form "value""suit"
     if (printBoard) { // If the user hasn't disabled command line updates
       System.out.print(sb); // Print the card
     }
   }
   frame.cardDisplay(cardStrings); // Prints the card to the frame
   System.out.println("");
 }
 /** runMenu() method runs from the main and allows entry of data etc */
 private void runMenu() {
   String response;
   do {
     printMenu();
     System.out.println("What would you like to do:");
     scan = new Scanner(System.in);
     response = scan.nextLine().toUpperCase();
     switch (response) {
       case "1":
         pack.printPack();
         break;
       case "2":
         pack.shuffleDeck();
         isShuffled = true;
         break;
       case "3":
         if (isShuffled) {
           dealCard();
         } else {
           System.out.println("Please shuffle the pack first");
         }
         break;
       case "4":
         int lastCard1 = cardStrings.size() - 1;
         movePileOntoPrevious(lastCard1, isAI, isLegal);
         break;
       case "5":
         int lastCard2 = cardStrings.size();
         movePileTwoPlacesLeft(lastCard2, isAI, isLegal);
         break;
       case "6":
         int parameter1 =
             getInt("What card do you want to move? (By it's position on the board)") - 1;
         movePileOntoPrevious(parameter1, isAI, isLegal);
         break;
       case "7":
         int parameter2 = getInt("What card do you want to move? (By it's position on the board)");
         movePileTwoPlacesLeft(parameter2, isAI, isLegal);
         break;
       case "8":
         AI();
         break;
       case "9":
         int numMoves = getInt("How many moves do you wish to make?");
         for (int i = 0; i < numMoves; i++) {
           if (!drawCard) { // If there are no cards left to draw, then stop.
             break;
           }
           AI();
         }
         break;
       case "10":
         toggleLog();
         break;
       case "11":
         togglePrintBoard();
         break;
       case "12":
         lowScores.printScores();
         break;
       case "Q":
         System.out.println("Your score was: " + cardStrings.size());
         saveScore();
         frame.closeProgram();
         break;
       default:
         System.err.println("Incorrect Selection, try again");
     }
   } while (!(response.equals("Q")));
 }