Assignment # P3 and Black Jack
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: BlackJack
/// File Name: BlackJack.java
/// Date: 5/8/16
import java.util.Scanner;
import java.util.Random;
public class BlackJack
{
public static void main(String[] args)
{
Random r= new Random();
Random x= new Random();
Scanner keyboard= new Scanner(System.in);
String move="";
String pGraphic1= "", pGraphic2= "", pGraphic3= ""; ///Player's card graphic
String dGraphic1= "", dGraphic2= "", dGraphic3= ""; ///Dealer's card graphic
int coins= 100, gamble;
int pCard1=0, pCard2=0, pCard3=0, pTotal = 0; ///Player's cards and total
int dCard1=0, dCard2= 0, dCard3= 0, dTotal= 0; /// Dealer's cards and total
int pCard1Value=0, pCard2Value=0, pCard3Value=0;
int dCard1Value=0, dCard2Value=0, dCard3Value=0;
int pSuit1=0, pSuit2=0, pSuit3=0;
int dSuit1, dSuit2, dSuit3;
System.out.println("Welcome to Blackjack!");
/// Player chooses how many coins to gamble
System.out.println();
System.out.print( "You have " + coins + " coins. How many would you like to gamble? The dealer matches the amount. " );
System.out.println();
gamble = keyboard.nextInt();
/// Checks to see if the gamble is within how many coins the player starts off with
while (gamble>coins||gamble<= 0)
{
System.out.print( "You must gamble between 1 & " + coins + "! How many would you like to gamble? " );
gamble = keyboard.nextInt();
}
coins= coins-gamble; /// Takes the player's gamble from their store of coins.
System.out.println("The dealer also gambles " + gamble + " coins.");
System.out.println("There are "+ (gamble*2) + " coins in total.");
System.out.println();
////////////////////////////////PLAYER'S FIRST CARD////////////////////////////////
pCard1 = 1 + r.nextInt(13);
pSuit1 = 1 + x.nextInt(4);
///Card value Ace
if (pCard1==1 && pSuit1==1)
{
pGraphic1=(" \n|--------|\n|A |\n| |\n| spades |\n| |\n| A |\n|--------|");
pCard1Value=11;
}
else if (pCard1== 1 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|A |\n| |\n| hearts |\n| |\n| A |\n|--------|");
pCard1Value=11;
}
else if (pCard1== 1 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|A |\n| |\n|diamonds|\n| |\n| A |\n|--------|");
pCard1Value=11;
}
else if (pCard1== 1 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|A |\n| |\n| clubs |\n| |\n| A |\n|--------|");
pCard1Value=11;
}
///Card value 2
else if (pCard1== 2 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|2 |\n| |\n| spades |\n| |\n| 2 |\n|--------|");
pCard1Value=11;
}
else if (pCard1== 2 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|2 |\n| |\n| hearts |\n| |\n| 2 |\n|--------|");
pCard1Value=2;
}
else if (pCard1== 2 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|2 |\n| |\n|diamonds|\n| |\n| 2 |\n|--------|");
pCard1Value=2;
}
else if (pCard1== 2 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|2 |\n| |\n| clubs |\n| |\n| 2 |\n|--------|");
pCard1Value=2;
}
///Card value 3
else if (pCard1== 3 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|3 |\n| |\n| spades |\n| |\n| 3 |\n|--------|");
pCard1Value=3;
}
else if (pCard1== 3 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|3 |\n| |\n| hearts |\n| |\n| 3 |\n|--------|");
pCard1Value=3;
}
else if (pCard1== 3 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|3 |\n| |\n|diamonds|\n| |\n| 3 |\n|--------|");
pCard1Value=3;
}
else if (pCard1== 3 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|3 |\n| |\n| clubs |\n| |\n| 3 |\n|--------|");
pCard1Value=3;
}
///Card value 4
else if (pCard1== 4 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|4 |\n| |\n| spades |\n| |\n| 4 |\n|--------|");
pCard1Value=4;
}
else if (pCard1== 4 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|4 |\n| |\n| hearts |\n| |\n| 4 |\n|--------|");
pCard1Value=4;
}
else if (pCard1== 4 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|4 |\n| |\n|diamonds|\n| |\n| 4 |\n|--------|");
pCard1Value=4;
}
else if (pCard1== 4 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|4 |\n| |\n| clubs |\n| |\n| 4 |\n|--------|");
pCard1Value=4;
}
///Card value 5
else if (pCard1== 5 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|5 |\n| |\n| spades |\n| |\n| 5 |\n|--------|");
pCard1Value=5;
}
else if (pCard1== 5 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|5 |\n| |\n| hearts |\n| |\n| 5 |\n|--------|");
pCard1Value=5;
}
else if (pCard1== 5 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|5 |\n| |\n|diamonds|\n| |\n| 5 |\n|--------|");
pCard1Value=5;
}
else if (pCard1== 5 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|5 |\n| |\n| clubs |\n| |\n| 5 |\n|--------|");
pCard1Value=5;
}
///Card value 6
else if (pCard1== 6 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|6 |\n| |\n| spades |\n| |\n| 6 |\n|--------|");
pCard1Value=6;
}
else if (pCard1== 6 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|6 |\n| |\n| hearts |\n| |\n| 6 |\n|--------|");
pCard1Value=6;
}
else if (pCard1== 6 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|6 |\n| |\n|diamonds|\n| |\n| 6 |\n|--------|");
pCard1Value=6;
}
else if (pCard1== 6 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|6 |\n| |\n| clubs |\n| |\n| 6 |\n|--------|");
pCard1Value=6;
}
///Card value 7
else if (pCard1== 7 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|7 |\n| |\n| spades |\n| |\n| 7 |\n|--------|");
pCard1Value=7;
}
else if (pCard1== 7 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|7 |\n| |\n| hearts |\n| |\n| 7 |\n|--------|");
pCard1Value=7;
}
else if (pCard1== 7 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|7 |\n| |\n|diamonds|\n| |\n| 7 |\n|--------|");
pCard1Value=7;
}
else if (pCard1== 7 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|7 |\n| |\n| clubs |\n| |\n| 7 |\n|--------|");
pCard1Value=7;
}
///Card value 8
else if (pCard1== 8 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|8 |\n| |\n| spades |\n| |\n| 8 |\n|--------|");
pCard1Value=8;
}
else if (pCard1== 8 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|8 |\n| |\n| hearts |\n| |\n| 8 |\n|--------|");
pCard1Value=8;
}
else if (pCard1== 8 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|8 |\n| |\n|diamonds|\n| |\n| 8 |\n|--------|");
pCard1Value=8;
}
else if (pCard1== 8 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|8 |\n| |\n| clubs |\n| |\n| 8 |\n|--------|");
pCard1Value=8;
}
///Card value 9
else if (pCard1== 9 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|9 |\n| |\n| spades |\n| |\n| 9 |\n|--------|");
pCard1Value=9;
}
else if (pCard1== 9 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|9 |\n| |\n| hearts |\n| |\n| 9 |\n|--------|");
pCard1Value=9;
}
else if (pCard1== 9 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|9 |\n| |\n|diamonds|\n| |\n| 9 |\n|--------|");
pCard1Value=9;
}
else if (pCard1== 9 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|9 |\n| |\n| clubs |\n| |\n| 9 |\n|--------|");
pCard1Value=9;
}
///Card value 10
else if (pCard1== 10 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|10 |\n| |\n| spades |\n| |\n| 10 |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 10 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|10 |\n| |\n| hearts |\n| |\n| 10 |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 10 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|10 |\n| |\n|diamonds|\n| |\n| 10 |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 10 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|10 |\n| |\n| clubs |\n| |\n| 10 |\n|--------|");
pCard1Value=10;
}
///Card value Jack
else if (pCard1== 11 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|J |\n| |\n| spades |\n| |\n| J |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 11 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|J |\n| |\n| hearts |\n| |\n| J |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 11 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|J |\n| |\n|diamonds|\n| |\n| J |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 11 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|J |\n| |\n| clubs |\n| |\n| J |\n|--------|");
pCard1Value=10;
}
///Card value Queen
else if (pCard1== 12 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|Q |\n| |\n| spades |\n| |\n| Q |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 12 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|Q |\n| |\n| hearts |\n| |\n| Q |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 12 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|Q |\n| |\n|diamonds|\n| |\n| Q |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 12 && pSuit1== 4)
{
pGraphic1=(" \n|--------|\n|Q |\n| |\n| clubs |\n| |\n| Q |\n|--------|");
pCard1Value=10;
}
///Card value King
else if (pCard1== 13 && pSuit1== 1)
{
pGraphic1=(" \n|--------|\n|K |\n| |\n| spades |\n| |\n| K |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 13 && pSuit1== 2)
{
pGraphic1=(" \n|--------|\n|K |\n| |\n| hearts |\n| |\n| K |\n|--------|");
pCard1Value=10;
}
else if (pCard1== 13 && pSuit1== 3)
{
pGraphic1=(" \n|--------|\n|K |\n| |\n|diamonds|\n| |\n| K |\n|--------|");
pCard1Value=10;
}
else
{
pGraphic1=(" \n|--------|\n|K |\n| |\n| clubs |\n| |\n| K |\n|--------|");
pCard1Value=10;
}
////////////////////////////////PLAYER'S SECOND CARD////////////////////////////////
pCard1 = 1 + r.nextInt(13);
pSuit1 = 1 + x.nextInt(4);
///Card value Ace
if (pCard2==1 && pSuit2==1)
{
pGraphic2=(" \n|--------|\n|A |\n| |\n| spades |\n| |\n| A |\n|--------|");
pCard2Value=11;
}
else if (pCard2== 1 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|A |\n| |\n| hearts |\n| |\n| A |\n|--------|");
pCard2Value=11;
}
else if (pCard2== 1 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|A |\n| |\n|diamonds|\n| |\n| A |\n|--------|");
pCard2Value=11;
}
else if (pCard2== 1 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|A |\n| |\n| clubs |\n| |\n| A |\n|--------|");
pCard2Value=11;
}
///Card value 2
else if (pCard2== 2 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|2 |\n| |\n| spades |\n| |\n| 2 |\n|--------|");
pCard2Value=2;
}
else if (pCard2== 2 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|2 |\n| |\n| hearts |\n| |\n| 2 |\n|--------|");
pCard2Value=2;
}
else if (pCard2== 2 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|2 |\n| |\n|diamonds|\n| |\n| 2 |\n|--------|");
pCard2Value=2;
}
else if (pCard2== 2 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|2 |\n| |\n| clubs |\n| |\n| 2 |\n|--------|");
pCard2Value=2;
}
///Card value 3
else if (pCard2== 3 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|3 |\n| |\n| spades |\n| |\n| 3 |\n|--------|");
pCard2Value=3;
}
else if (pCard2== 3 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|3 |\n| |\n| hearts |\n| |\n| 3 |\n|--------|");
pCard2Value=3;
}
else if (pCard2== 3 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|3 |\n| |\n|diamonds|\n| |\n| 3 |\n|--------|");
pCard2Value=3;
}
else if (pCard2== 3 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|3 |\n| |\n| clubs |\n| |\n| 3 |\n|--------|");
pCard2Value=3;
}
///Card value 4
else if (pCard2== 4 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|4 |\n| |\n| spades |\n| |\n| 4 |\n|--------|");
pCard2Value=4;
}
else if (pCard2== 4 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|4 |\n| |\n| hearts |\n| |\n| 4 |\n|--------|");
pCard2Value=4;
}
else if (pCard2== 4 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|4 |\n| |\n|diamonds|\n| |\n| 4 |\n|--------|");
pCard2Value=4;
}
else if (pCard2== 4 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|4 |\n| |\n| clubs |\n| |\n| 4 |\n|--------|");
pCard2Value=4;
}
///Card value 5
else if (pCard2== 5 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|5 |\n| |\n| spades |\n| |\n| 5 |\n|--------|");
pCard2Value=5;
}
else if (pCard2== 5 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|5 |\n| |\n| hearts |\n| |\n| 5 |\n|--------|");
pCard2Value=5;
}
else if (pCard2== 5 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|5 |\n| |\n|diamonds|\n| |\n| 5 |\n|--------|");
pCard2Value=5;
}
else if (pCard2== 5 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|5 |\n| |\n| clubs |\n| |\n| 5 |\n|--------|");
pCard2Value=5;
}
///Card value 6
else if (pCard2== 6 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|6 |\n| |\n| spades |\n| |\n| 6 |\n|--------|");
pCard2Value=6;
}
else if (pCard2== 6 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|6 |\n| |\n| hearts |\n| |\n| 6 |\n|--------|");
pCard2Value=6;
}
else if (pCard2== 6 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|6 |\n| |\n|diamonds|\n| |\n| 6 |\n|--------|");
pCard2Value=6;
}
else if (pCard2== 6 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|6 |\n| |\n| clubs |\n| |\n| 6 |\n|--------|");
pCard2Value=6;
}
///Card value 7
else if (pCard2== 7 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|7 |\n| |\n| spades |\n| |\n| 7 |\n|--------|");
pCard2Value=7;
}
else if (pCard2== 7 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|7 |\n| |\n| hearts |\n| |\n| 7 |\n|--------|");
pCard2Value=7;
}
else if (pCard2== 7 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|7 |\n| |\n|diamonds|\n| |\n| 7 |\n|--------|");
pCard2Value=7;
}
else if (pCard2== 7 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|7 |\n| |\n| clubs |\n| |\n| 7 |\n|--------|");
pCard2Value=7;
}
///Card value 8
else if (pCard2== 8 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|8 |\n| |\n| spades |\n| |\n| 8 |\n|--------|");
pCard2Value=8;
}
else if (pCard2== 8 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|8 |\n| |\n| hearts |\n| |\n| 8 |\n|--------|");
pCard2Value=8;
}
else if (pCard2== 8 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|8 |\n| |\n|diamonds|\n| |\n| 8 |\n|--------|");
pCard2Value=8;
}
else if (pCard2== 8 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|8 |\n| |\n| clubs |\n| |\n| 8 |\n|--------|");
pCard2Value=8;
}
///Card value 9
else if (pCard2== 9 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|9 |\n| |\n| spades |\n| |\n| 9 |\n|--------|");
pCard2Value=9;
}
else if (pCard2== 9 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|9 |\n| |\n| hearts |\n| |\n| 9 |\n|--------|");
pCard2Value=9;
}
else if (pCard2== 9 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|9 |\n| |\n|diamonds|\n| |\n| 9 |\n|--------|");
pCard2Value=9;
}
else if (pCard2== 9 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|9 |\n| |\n| clubs |\n| |\n| 9 |\n|--------|");
pCard2Value=9;
}
///Card value 10
else if (pCard2== 10 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|10 |\n| |\n| spades |\n| |\n| 10 |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 10 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|10 |\n| |\n| hearts |\n| |\n| 10 |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 10 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|10 |\n| |\n|diamonds|\n| |\n| 10 |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 10 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|10 |\n| |\n| clubs |\n| |\n| 10 |\n|--------|");
pCard2Value=10;
}
///Card value Jack
else if (pCard2== 11 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|J |\n| |\n| spades |\n| |\n| J |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 11 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|J |\n| |\n| hearts |\n| |\n| J |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 11 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|J |\n| |\n|diamonds|\n| |\n| J |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 11 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|J |\n| |\n| clubs |\n| |\n| J |\n|--------|");
pCard2Value=10;
}
///Card value Queen
else if (pCard2== 12 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|Q |\n| |\n| spades |\n| |\n| Q |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 12 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|Q |\n| |\n| hearts |\n| |\n| Q |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 12 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|Q |\n| |\n|diamonds|\n| |\n| Q |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 12 && pSuit2== 4)
{
pGraphic2=(" \n|--------|\n|Q |\n| |\n| clubs |\n| |\n| Q |\n|--------|");
pCard2Value=10;
}
///Card value King
else if (pCard2== 13 && pSuit2== 1)
{
pGraphic2=(" \n|--------|\n|K |\n| |\n| spades |\n| |\n| K |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 13 && pSuit2== 2)
{
pGraphic2=(" \n|--------|\n|K |\n| |\n| hearts |\n| |\n| K |\n|--------|");
pCard2Value=10;
}
else if (pCard2== 13 && pSuit2== 3)
{
pGraphic2=(" \n|--------|\n|K |\n| |\n|diamonds|\n| |\n| K |\n|--------|");
pCard2Value=10;
}
else
{
pGraphic2=(" \n|--------|\n|K |\n| |\n| clubs |\n| |\n| K |\n|--------|");
pCard2Value=10;
}
System.out.println("Your first card is " + pGraphic1+ "\nand your second card is " +pGraphic2);
pTotal= pTotal+ pCard1Value+ pCard2Value;
System.out.println("Your total is "+ pTotal+ ".");
System.out.println();
if (pTotal<= 21) //Goes to the end of the game if the player busts
{
////////////////////////////////DEALER'S FIRST CARD////////////////////////////////
dCard1 = 1 + r.nextInt(13);
dSuit1= 1 + x.nextInt(4);
///Card value Ace
if (dCard1==1 && dSuit1==1)
{
dGraphic1=(" \n|--------|\n|A |\n| |\n| spades |\n| |\n| A |\n|--------|");
dCard1Value=11;
}
else if (pCard1== 1 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|A |\n| |\n| hearts |\n| |\n| A |\n|--------|");
dCard1Value=11;
}
else if (dCard1== 1 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|A |\n| |\n|diamonds|\n| |\n| A |\n|--------|");
dCard1Value=11;
}
else if (dCard1== 1 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|A |\n| |\n| clubs |\n| |\n| A |\n|--------|");
dCard1Value=11;
}
///Card value 2
else if (dCard1== 2 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|2 |\n| |\n| spades |\n| |\n| 2 |\n|--------|");
dCard1Value=11;
}
else if (dCard1== 2 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|2 |\n| |\n| hearts |\n| |\n| 2 |\n|--------|");
dCard1Value=2;
}
else if (dCard1== 2 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|2 |\n| |\n|diamonds|\n| |\n| 2 |\n|--------|");
dCard1Value=2;
}
else if (dCard1== 2 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|2 |\n| |\n| clubs |\n| |\n| 2 |\n|--------|");
dCard1Value=2;
}
///Card value 3
else if (dCard1== 3 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|3 |\n| |\n| spades |\n| |\n| 3 |\n|--------|");
dCard1Value=3;
}
else if (dCard1== 3 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|3 |\n| |\n| hearts |\n| |\n| 3 |\n|--------|");
dCard1Value=3;
}
else if (dCard1== 3 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|3 |\n| |\n|diamonds|\n| |\n| 3 |\n|--------|");
dCard1Value=3;
}
else if (dCard1== 3 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|3 |\n| |\n| clubs |\n| |\n| 3 |\n|--------|");
dCard1Value=3;
}
///Card value 4
else if (dCard1== 4 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|4 |\n| |\n| spades |\n| |\n| 4 |\n|--------|");
dCard1Value=4;
}
else if (dCard1== 4 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|4 |\n| |\n| hearts |\n| |\n| 4 |\n|--------|");
dCard1Value=4;
}
else if (dCard1== 4 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|4 |\n| |\n|diamonds|\n| |\n| 4 |\n|--------|");
dCard1Value=4;
}
else if (dCard1== 4 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|4 |\n| |\n| clubs |\n| |\n| 4 |\n|--------|");
dCard1Value=4;
}
///Card value 5
else if (dCard1== 5 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|5 |\n| |\n| spades |\n| |\n| 5 |\n|--------|");
dCard1Value=5;
}
else if (dCard1== 5 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|5 |\n| |\n| hearts |\n| |\n| 5 |\n|--------|");
dCard1Value=5;
}
else if (dCard1== 5 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|5 |\n| |\n|diamonds|\n| |\n| 5 |\n|--------|");
dCard1Value=5;
}
else if (dCard1== 5 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|5 |\n| |\n| clubs |\n| |\n| 5 |\n|--------|");
dCard1Value=5;
}
///Card value 6
else if (dCard1== 6 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|6 |\n| |\n| spades |\n| |\n| 6 |\n|--------|");
dCard1Value=6;
}
else if (dCard1== 6 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|6 |\n| |\n| hearts |\n| |\n| 6 |\n|--------|");
dCard1Value=6;
}
else if (dCard1== 6 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|6 |\n| |\n|diamonds|\n| |\n| 6 |\n|--------|");
dCard1Value=6;
}
else if (dCard1== 6 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|6 |\n| |\n| clubs |\n| |\n| 6 |\n|--------|");
dCard1Value=6;
}
///Card value 7
else if (dCard1== 7 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|7 |\n| |\n| spades |\n| |\n| 7 |\n|--------|");
dCard1Value=7;
}
else if (dCard1== 7 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|7 |\n| |\n| hearts |\n| |\n| 7 |\n|--------|");
dCard1Value=7;
}
else if (dCard1== 7 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|7 |\n| |\n|diamonds|\n| |\n| 7 |\n|--------|");
dCard1Value=7;
}
else if (dCard1== 7 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|7 |\n| |\n| clubs |\n| |\n| 7 |\n|--------|");
dCard1Value=7;
}
///Card value 8
else if (dCard1== 8 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|8 |\n| |\n| spades |\n| |\n| 8 |\n|--------|");
dCard1Value=8;
}
else if (dCard1== 8 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|8 |\n| |\n| hearts |\n| |\n| 8 |\n|--------|");
dCard1Value=8;
}
else if (dCard1== 8 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|8 |\n| |\n|diamonds|\n| |\n| 8 |\n|--------|");
dCard1Value=8;
}
else if (dCard1== 8 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|8 |\n| |\n| clubs |\n| |\n| 8 |\n|--------|");
dCard1Value=8;
}
///Card value 9
else if (dCard1== 9 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|9 |\n| |\n| spades |\n| |\n| 9 |\n|--------|");
dCard1Value=9;
}
else if (dCard1== 9 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|9 |\n| |\n| hearts |\n| |\n| 9 |\n|--------|");
dCard1Value=9;
}
else if (dCard1== 9 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|9 |\n| |\n|diamonds|\n| |\n| 9 |\n|--------|");
dCard1Value=9;
}
else if (dCard1== 9 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|9 |\n| |\n| clubs |\n| |\n| 9 |\n|--------|");
dCard1Value=9;
}
///Card value 10
else if (dCard1== 10 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|10 |\n| |\n| spades |\n| |\n| 10 |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 10 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|10 |\n| |\n| hearts |\n| |\n| 10 |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 10 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|10 |\n| |\n|diamonds|\n| |\n| 10 |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 10 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|10 |\n| |\n| clubs |\n| |\n| 10 |\n|--------|");
dCard1Value=10;
}
///Card value Jack
else if (dCard1== 11 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|J |\n| |\n| spades |\n| |\n| J |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 11 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|J |\n| |\n| hearts |\n| |\n| J |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 11 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|J |\n| |\n|diamonds|\n| |\n| J |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 11 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|J |\n| |\n| clubs |\n| |\n| J |\n|--------|");
dCard1Value=10;
}
///Card value Queen
else if (dCard1== 12 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|Q |\n| |\n| spades |\n| |\n| Q |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 12 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|Q |\n| |\n| hearts |\n| |\n| Q |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 12 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|Q |\n| |\n|diamonds|\n| |\n| Q |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 12 && dSuit1== 4)
{
dGraphic1=(" \n|--------|\n|Q |\n| |\n| clubs |\n| |\n| Q |\n|--------|");
dCard1Value=10;
}
///Card value King
else if (dCard1== 13 && dSuit1== 1)
{
dGraphic1=(" \n|--------|\n|K |\n| |\n| spades |\n| |\n| K |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 13 && dSuit1== 2)
{
dGraphic1=(" \n|--------|\n|K |\n| |\n| hearts |\n| |\n| K |\n|--------|");
dCard1Value=10;
}
else if (dCard1== 13 && dSuit1== 3)
{
dGraphic1=(" \n|--------|\n|K |\n| |\n|diamonds|\n| |\n| K |\n|--------|");
dCard1Value=10;
}
else
{
dGraphic1=(" \n|--------|\n|K |\n| |\n| clubs |\n| |\n| K |\n|--------|");
dCard1Value=10;
}
////////////////////////////////DEALER'S SECOND CARD////////////////////////////////
dCard2 = 1 + r.nextInt(13);
dSuit2= 1+ x.nextInt(4);
///Card value Ace
if (dCard2==1 && dSuit2==1)
{
dGraphic2=(" \n|--------|\n|A |\n| |\n| spades |\n| |\n| A |\n|--------|");
dCard2Value=11;
}
else if (dCard2== 1 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|A |\n| |\n| hearts |\n| |\n| A |\n|--------|");
dCard2Value=11;
}
else if (dCard2== 1 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|A |\n| |\n|diamonds|\n| |\n| A |\n|--------|");
dCard2Value=11;
}
else if (dCard2== 1 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|A |\n| |\n| clubs |\n| |\n| A |\n|--------|");
dCard2Value=11;
}
///Card value 2
else if (dCard2== 2 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|2 |\n| |\n| spades |\n| |\n| 2 |\n|--------|");
dCard2Value=2;
}
else if (dCard2== 2 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|2 |\n| |\n| hearts |\n| |\n| 2 |\n|--------|");
dCard2Value=2;
}
else if (dCard2== 2 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|2 |\n| |\n|diamonds|\n| |\n| 2 |\n|--------|");
dCard2Value=2;
}
else if (dCard2== 2 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|2 |\n| |\n| clubs |\n| |\n| 2 |\n|--------|");
dCard2Value=2;
}
///Card value 3
else if (dCard2== 3 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|3 |\n| |\n| spades |\n| |\n| 3 |\n|--------|");
dCard2Value=3;
}
else if (dCard2== 3 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|3 |\n| |\n| hearts |\n| |\n| 3 |\n|--------|");
dCard2Value=3;
}
else if (dCard2== 3 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|3 |\n| |\n|diamonds|\n| |\n| 3 |\n|--------|");
dCard2Value=3;
}
else if (dCard2== 3 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|3 |\n| |\n| clubs |\n| |\n| 3 |\n|--------|");
dCard2Value=3;
}
///Card value 4
else if (dCard2== 4 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|4 |\n| |\n| spades |\n| |\n| 4 |\n|--------|");
dCard2Value=4;
}
else if (dCard2== 4 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|4 |\n| |\n| hearts |\n| |\n| 4 |\n|--------|");
dCard2Value=4;
}
else if (dCard2== 4 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|4 |\n| |\n|diamonds|\n| |\n| 4 |\n|--------|");
dCard2Value=4;
}
else if (dCard2== 4 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|4 |\n| |\n| clubs |\n| |\n| 4 |\n|--------|");
dCard2Value=4;
}
///Card value 5
else if (dCard2== 5 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|5 |\n| |\n| spades |\n| |\n| 5 |\n|--------|");
dCard2Value=5;
}
else if (dCard2== 5 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|5 |\n| |\n| hearts |\n| |\n| 5 |\n|--------|");
dCard2Value=5;
}
else if (dCard2== 5 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|5 |\n| |\n|diamonds|\n| |\n| 5 |\n|--------|");
dCard2Value=5;
}
else if (dCard2== 5 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|5 |\n| |\n| clubs |\n| |\n| 5 |\n|--------|");
dCard2Value=5;
}
///Card value 6
else if (dCard2== 6 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|6 |\n| |\n| spades |\n| |\n| 6 |\n|--------|");
dCard2Value=6;
}
else if (dCard2== 6 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|6 |\n| |\n| hearts |\n| |\n| 6 |\n|--------|");
dCard2Value=6;
}
else if (dCard2== 6 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|6 |\n| |\n|diamonds|\n| |\n| 6 |\n|--------|");
dCard2Value=6;
}
else if (dCard2== 6 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|6 |\n| |\n| clubs |\n| |\n| 6 |\n|--------|");
dCard2Value=6;
}
///Card value 7
else if (dCard2== 7 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|7 |\n| |\n| spades |\n| |\n| 7 |\n|--------|");
dCard2Value=7;
}
else if (dCard2== 7 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|7 |\n| |\n| hearts |\n| |\n| 7 |\n|--------|");
dCard2Value=7;
}
else if (dCard2== 7 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|7 |\n| |\n|diamonds|\n| |\n| 7 |\n|--------|");
dCard2Value=7;
}
else if (dCard2== 7 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|7 |\n| |\n| clubs |\n| |\n| 7 |\n|--------|");
dCard2Value=7;
}
///Card value 8
else if (dCard2== 8 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|8 |\n| |\n| spades |\n| |\n| 8 |\n|--------|");
dCard2Value=8;
}
else if (dCard2== 8 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|8 |\n| |\n| hearts |\n| |\n| 8 |\n|--------|");
dCard2Value=8;
}
else if (dCard2== 8 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|8 |\n| |\n|diamonds|\n| |\n| 8 |\n|--------|");
dCard2Value=8;
}
else if (dCard2== 8 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|8 |\n| |\n| clubs |\n| |\n| 8 |\n|--------|");
dCard2Value=8;
}
///Card value 9
else if (dCard2== 9 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|9 |\n| |\n| spades |\n| |\n| 9 |\n|--------|");
dCard2Value=9;
}
else if (dCard2== 9 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|9 |\n| |\n| hearts |\n| |\n| 9 |\n|--------|");
dCard2Value=9;
}
else if (dCard2== 9 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|9 |\n| |\n|diamonds|\n| |\n| 9 |\n|--------|");
dCard2Value=9;
}
else if (dCard2== 9 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|9 |\n| |\n| clubs |\n| |\n| 9 |\n|--------|");
dCard2Value=9;
}
///Card value 10
else if (dCard2== 10 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|10 |\n| |\n| spades |\n| |\n| 10 |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 10 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|10 |\n| |\n| hearts |\n| |\n| 10 |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 10 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|10 |\n| |\n|diamonds|\n| |\n| 10 |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 10 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|10 |\n| |\n| clubs |\n| |\n| 10 |\n|--------|");
dCard2Value=10;
}
///Card value Jack
else if (dCard2== 11 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|J |\n| |\n| spades |\n| |\n| J |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 11 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|J |\n| |\n| hearts |\n| |\n| J |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 11 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|J |\n| |\n|diamonds|\n| |\n| J |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 11 && dSuit2== 4)
{
pGraphic2=(" \n|--------|\n|J |\n| |\n| clubs |\n| |\n| J |\n|--------|");
pCard2Value=10;
}
///Card value Queen
else if (dCard2== 12 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|Q |\n| |\n| spades |\n| |\n| Q |\n|--------|");
dCard2Value=10;
}
else if (pCard2== 12 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|Q |\n| |\n| hearts |\n| |\n| Q |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 12 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|Q |\n| |\n|diamonds|\n| |\n| Q |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 12 && dSuit2== 4)
{
dGraphic2=(" \n|--------|\n|Q |\n| |\n| clubs |\n| |\n| Q |\n|--------|");
dCard2Value=10;
}
///Card value King
else if (dCard2== 13 && dSuit2== 1)
{
dGraphic2=(" \n|--------|\n|K |\n| |\n| spades |\n| |\n| K |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 13 && dSuit2== 2)
{
dGraphic2=(" \n|--------|\n|K |\n| |\n| hearts |\n| |\n| K |\n|--------|");
dCard2Value=10;
}
else if (dCard2== 13 && dSuit2== 3)
{
dGraphic2=(" \n|--------|\n|K |\n| |\n|diamonds|\n| |\n| K |\n|--------|");
dCard2Value=10;
}
else
{
dGraphic2=(" \n|--------|\n|K |\n| |\n| clubs |\n| |\n| K |\n|--------|");
dCard2Value=10;
}
System.out.println("The dealer's first card is "+ dGraphic1+ "\nand his second card is hidden." );
dTotal= dCard1Value+ dCard2Value;
System.out.println("The dealer's total is also hidden.");
System.out.println();
System.out.print("Would you like to hit or stay? ");
move= keyboard.next();
}
///Player's gets another card if hit
while (move.equals("hit")&& (pTotal<= 21))
{
////////////////////////////////PLAYER'S THIRD CARD////////////////////////////////
pCard1 = 1 + r.nextInt(13);
pSuit1 = 1 + x.nextInt(4);
///Card value Ace
if (pCard3==1 && pSuit3==1)
{
pGraphic3=(" \n|--------|\n|A |\n| |\n| spades |\n| |\n| A |\n|--------|");
pCard3Value=11;
}
else if (pCard3== 1 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|A |\n| |\n| hearts |\n| |\n| A |\n|--------|");
pCard3Value=11;
}
else if (pCard3== 1 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|A |\n| |\n|diamonds|\n| |\n| A |\n|--------|");
pCard3Value=11;
}
else if (pCard3== 1 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|A |\n| |\n| clubs |\n| |\n| A |\n|--------|");
pCard3Value=11;
}
///Card value 2
else if (pCard3== 2 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|2 |\n| |\n| spades |\n| |\n| 2 |\n|--------|");
pCard3Value=2;
}
else if (pCard2== 2 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|2 |\n| |\n| hearts |\n| |\n| 2 |\n|--------|");
pCard3Value=2;
}
else if (pCard2== 2 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|2 |\n| |\n|diamonds|\n| |\n| 2 |\n|--------|");
pCard3Value=2;
}
else if (pCard3== 2 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|2 |\n| |\n| clubs |\n| |\n| 2 |\n|--------|");
pCard3Value=2;
}
///Card value 3
else if (pCard2== 3 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|3 |\n| |\n| spades |\n| |\n| 3 |\n|--------|");
pCard3Value=3;
}
else if (pCard3== 3 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|3 |\n| |\n| hearts |\n| |\n| 3 |\n|--------|");
pCard3Value=3;
}
else if (pCard3== 3 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|3 |\n| |\n|diamonds|\n| |\n| 3 |\n|--------|");
pCard3Value=3;
}
else if (pCard3== 3 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|3 |\n| |\n| clubs |\n| |\n| 3 |\n|--------|");
pCard3Value=3;
}
///Card value 4
else if (pCard3== 4 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|4 |\n| |\n| spades |\n| |\n| 4 |\n|--------|");
pCard3Value=4;
}
else if (pCard3== 4 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|4 |\n| |\n| hearts |\n| |\n| 4 |\n|--------|");
pCard3Value=4;
}
else if (pCard3== 4 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|4 |\n| |\n|diamonds|\n| |\n| 4 |\n|--------|");
pCard3Value=4;
}
else if (pCard3== 4 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|4 |\n| |\n| clubs |\n| |\n| 4 |\n|--------|");
pCard3Value=4;
}
///Card value 5
else if (pCard3== 5 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|5 |\n| |\n| spades |\n| |\n| 5 |\n|--------|");
pCard3Value=5;
}
else if (pCard3== 5 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|5 |\n| |\n| hearts |\n| |\n| 5 |\n|--------|");
pCard3Value=5;
}
else if (pCard3== 5 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|5 |\n| |\n|diamonds|\n| |\n| 5 |\n|--------|");
pCard3Value=5;
}
else if (pCard3== 5 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|5 |\n| |\n| clubs |\n| |\n| 5 |\n|--------|");
pCard3Value=5;
}
///Card value 6
else if (pCard3== 6 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|6 |\n| |\n| spades |\n| |\n| 6 |\n|--------|");
pCard3Value=6;
}
else if (pCard3== 6 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|6 |\n| |\n| hearts |\n| |\n| 6 |\n|--------|");
pCard3Value=6;
}
else if (pCard3== 6 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|6 |\n| |\n|diamonds|\n| |\n| 6 |\n|--------|");
pCard3Value=6;
}
else if (pCard3== 6 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|6 |\n| |\n| clubs |\n| |\n| 6 |\n|--------|");
pCard3Value=6;
}
///Card value 7
else if (pCard3== 7 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|7 |\n| |\n| spades |\n| |\n| 7 |\n|--------|");
pCard3Value=7;
}
else if (pCard3== 7 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|7 |\n| |\n| hearts |\n| |\n| 7 |\n|--------|");
pCard3Value=7;
}
else if (pCard3== 7 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|7 |\n| |\n|diamonds|\n| |\n| 7 |\n|--------|");
pCard3Value=7;
}
else if (pCard3== 7 && pSuit3== 4)
{
pGraphic2=(" \n|--------|\n|7 |\n| |\n| clubs |\n| |\n| 7 |\n|--------|");
pCard2Value=7;
}
///Card value 8
else if (pCard3== 8 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|8 |\n| |\n| spades |\n| |\n| 8 |\n|--------|");
pCard3Value=8;
}
else if (pCard3== 8 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|8 |\n| |\n| hearts |\n| |\n| 8 |\n|--------|");
pCard3Value=8;
}
else if (pCard3== 8 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|8 |\n| |\n|diamonds|\n| |\n| 8 |\n|--------|");
pCard3Value=8;
}
else if (pCard3== 8 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|8 |\n| |\n| clubs |\n| |\n| 8 |\n|--------|");
pCard3Value=8;
}
///Card value 9
else if (pCard3== 9 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|9 |\n| |\n| spades |\n| |\n| 9 |\n|--------|");
pCard3Value=9;
}
else if (pCard3== 9 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|9 |\n| |\n| hearts |\n| |\n| 9 |\n|--------|");
pCard3Value=9;
}
else if (pCard3== 9 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|9 |\n| |\n|diamonds|\n| |\n| 9 |\n|--------|");
pCard3Value=9;
}
else if (pCard3== 9 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|9 |\n| |\n| clubs |\n| |\n| 9 |\n|--------|");
pCard3Value=9;
}
///Card value 10
else if (pCard3== 10 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|10 |\n| |\n| spades |\n| |\n| 10 |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 10 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|10 |\n| |\n| hearts |\n| |\n| 10 |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 10 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|10 |\n| |\n|diamonds|\n| |\n| 10 |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 10 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|10 |\n| |\n| clubs |\n| |\n| 10 |\n|--------|");
pCard3Value=10;
}
///Card value Jack
else if (pCard3== 11 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|J |\n| |\n| spades |\n| |\n| J |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 11 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|J |\n| |\n| hearts |\n| |\n| J |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 11 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|J |\n| |\n|diamonds|\n| |\n| J |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 11 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|J |\n| |\n| clubs |\n| |\n| J |\n|--------|");
pCard3Value=10;
}
///Card value Queen
else if (pCard3== 12 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|Q |\n| |\n| spades |\n| |\n| Q |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 12 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|Q |\n| |\n| hearts |\n| |\n| Q |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 12 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|Q |\n| |\n|diamonds|\n| |\n| Q |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 12 && pSuit3== 4)
{
pGraphic3=(" \n|--------|\n|Q |\n| |\n| clubs |\n| |\n| Q |\n|--------|");
pCard3Value=10;
}
///Card value King
else if (pCard3== 13 && pSuit3== 1)
{
pGraphic3=(" \n|--------|\n|K |\n| |\n| spades |\n| |\n| K |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 13 && pSuit3== 2)
{
pGraphic3=(" \n|--------|\n|K |\n| |\n| hearts |\n| |\n| K |\n|--------|");
pCard3Value=10;
}
else if (pCard3== 13 && pSuit3== 3)
{
pGraphic3=(" \n|--------|\n|K |\n| |\n|diamonds|\n| |\n| K |\n|--------|");
pCard3Value=10;
}
else
{
pGraphic3=(" \n|--------|\n|K |\n| |\n| clubs |\n| |\n| K |\n|--------|");
pCard3Value=10;
}
System.out.println("You drew "+ pGraphic3);
pTotal= pTotal+ pCard3Value;
System.out.println("Your total is "+ pTotal+ ".");
System.out.println();
if (pTotal<= 21) ///Player's move again if not yet at 21
{
System.out.print("Would you like to hit or stay? ");
move= keyboard.next();
}
}
///Dealer's turn after player stays and hasn't reached 21
if (pTotal<= 21)
{
System.out.println();
System.out.println("Dealer's turn.");
System.out.println("His hidden card was " +dGraphic2);
System.out.println("His total is " + dTotal + ".");
System.out.println();
///Dealer hits if total is less than 16
while ((dTotal<= 16)&& (pTotal<= 21))
{
System.out.println("Dealer chooses to hit.");
////////////////////////////////DEALER'S SECOND CARD////////////////////////////////
dCard3= 1+ r.nextInt(13);
dSuit3= 1+ x.nextInt(4);
///Card value Ace
if (dCard3==1 && dSuit3==1)
{
dGraphic3=(" \n|--------|\n|A |\n| |\n| spades |\n| |\n| A |\n|--------|");
dCard3Value=11;
}
else if (dCard3== 1 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|A |\n| |\n| hearts |\n| |\n| A |\n|--------|");
dCard3Value=11;
}
else if (dCard3== 1 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|A |\n| |\n|diamonds|\n| |\n| A |\n|--------|");
dCard3Value=11;
}
else if (dCard3== 1 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|A |\n| |\n| clubs |\n| |\n| A |\n|--------|");
dCard3Value=11;
}
///Card value 2
else if (dCard3== 2 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|2 |\n| |\n| spades |\n| |\n| 2 |\n|--------|");
dCard3Value=2;
}
else if (dCard2== 2 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|2 |\n| |\n| hearts |\n| |\n| 2 |\n|--------|");
dCard3Value=2;
}
else if (dCard2== 2 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|2 |\n| |\n|diamonds|\n| |\n| 2 |\n|--------|");
dCard3Value=2;
}
else if (dCard3== 2 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|2 |\n| |\n| clubs |\n| |\n| 2 |\n|--------|");
dCard3Value=2;
}
///Card value 3
else if (dCard2== 3 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|3 |\n| |\n| spades |\n| |\n| 3 |\n|--------|");
dCard3Value=3;
}
else if (dCard3== 3 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|3 |\n| |\n| hearts |\n| |\n| 3 |\n|--------|");
dCard3Value=3;
}
else if (dCard3== 3 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|3 |\n| |\n|diamonds|\n| |\n| 3 |\n|--------|");
dCard3Value=3;
}
else if (dCard3== 3 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|3 |\n| |\n| clubs |\n| |\n| 3 |\n|--------|");
dCard3Value=3;
}
///Card value 4
else if (dCard3== 4 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|4 |\n| |\n| spades |\n| |\n| 4 |\n|--------|");
dCard3Value=4;
}
else if (dCard3== 4 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|4 |\n| |\n| hearts |\n| |\n| 4 |\n|--------|");
dCard3Value=4;
}
else if (dCard3== 4 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|4 |\n| |\n|diamonds|\n| |\n| 4 |\n|--------|");
dCard3Value=4;
}
else if (dCard3== 4 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|4 |\n| |\n| clubs |\n| |\n| 4 |\n|--------|");
dCard3Value=4;
}
///Card value 5
else if (dCard3== 5 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|5 |\n| |\n| spades |\n| |\n| 5 |\n|--------|");
dCard3Value=5;
}
else if (dCard3== 5 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|5 |\n| |\n| hearts |\n| |\n| 5 |\n|--------|");
dCard3Value=5;
}
else if (dCard3== 5 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|5 |\n| |\n|diamonds|\n| |\n| 5 |\n|--------|");
dCard3Value=5;
}
else if (dCard3== 5 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|5 |\n| |\n| clubs |\n| |\n| 5 |\n|--------|");
dCard3Value=5;
}
///Card value 6
else if (dCard3== 6 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|6 |\n| |\n| spades |\n| |\n| 6 |\n|--------|");
dCard3Value=6;
}
else if (dCard3== 6 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|6 |\n| |\n| hearts |\n| |\n| 6 |\n|--------|");
dCard3Value=6;
}
else if (dCard3== 6 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|6 |\n| |\n|diamonds|\n| |\n| 6 |\n|--------|");
dCard3Value=6;
}
else if (dCard3== 6 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|6 |\n| |\n| clubs |\n| |\n| 6 |\n|--------|");
dCard3Value=6;
}
///Card value 7
else if (dCard3== 7 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|7 |\n| |\n| spades |\n| |\n| 7 |\n|--------|");
dCard3Value=7;
}
else if (dCard3== 7 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|7 |\n| |\n| hearts |\n| |\n| 7 |\n|--------|");
dCard3Value=7;
}
else if (dCard3== 7 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|7 |\n| |\n|diamonds|\n| |\n| 7 |\n|--------|");
dCard3Value=7;
}
else if (dCard3== 7 && dSuit3== 4)
{
dGraphic2=(" \n|--------|\n|7 |\n| |\n| clubs |\n| |\n| 7 |\n|--------|");
dCard2Value=7;
}
///Card value 8
else if (dCard3== 8 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|8 |\n| |\n| spades |\n| |\n| 8 |\n|--------|");
dCard3Value=8;
}
else if (dCard3== 8 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|8 |\n| |\n| hearts |\n| |\n| 8 |\n|--------|");
dCard3Value=8;
}
else if (dCard3== 8 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|8 |\n| |\n|diamonds|\n| |\n| 8 |\n|--------|");
dCard3Value=8;
}
else if (dCard3== 8 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|8 |\n| |\n| clubs |\n| |\n| 8 |\n|--------|");
dCard3Value=8;
}
///Card value 9
else if (dCard3== 9 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|9 |\n| |\n| spades |\n| |\n| 9 |\n|--------|");
dCard3Value=9;
}
else if (dCard3== 9 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|9 |\n| |\n| hearts |\n| |\n| 9 |\n|--------|");
dCard3Value=9;
}
else if (dCard3== 9 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|9 |\n| |\n|diamonds|\n| |\n| 9 |\n|--------|");
dCard3Value=9;
}
else if (dCard3== 9 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|9 |\n| |\n| clubs |\n| |\n| 9 |\n|--------|");
dCard3Value=9;
}
///Card value 10
else if (dCard3== 10 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|10 |\n| |\n| spades |\n| |\n| 10 |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 10 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|10 |\n| |\n| hearts |\n| |\n| 10 |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 10 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|10 |\n| |\n|diamonds|\n| |\n| 10 |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 10 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|10 |\n| |\n| clubs |\n| |\n| 10 |\n|--------|");
dCard3Value=10;
}
///Card value Jack
else if (dCard3== 11 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|J |\n| |\n| spades |\n| |\n| J |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 11 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|J |\n| |\n| hearts |\n| |\n| J |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 11 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|J |\n| |\n|diamonds|\n| |\n| J |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 11 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|J |\n| |\n| clubs |\n| |\n| J |\n|--------|");
dCard3Value=10;
}
///Card value Queen
else if (dCard3== 12 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|Q |\n| |\n| spades |\n| |\n| Q |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 12 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|Q |\n| |\n| hearts |\n| |\n| Q |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 12 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|Q |\n| |\n|diamonds|\n| |\n| Q |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 12 && dSuit3== 4)
{
dGraphic3=(" \n|--------|\n|Q |\n| |\n| clubs |\n| |\n| Q |\n|--------|");
dCard3Value=10;
}
///Card value King
else if (dCard3== 13 && dSuit3== 1)
{
dGraphic3=(" \n|--------|\n|K |\n| |\n| spades |\n| |\n| K |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 13 && dSuit3== 2)
{
dGraphic3=(" \n|--------|\n|K |\n| |\n| hearts |\n| |\n| K |\n|--------|");
dCard3Value=10;
}
else if (dCard3== 13 && dSuit3== 3)
{
dGraphic3=(" \n|--------|\n|K |\n| |\n|diamonds|\n| |\n| K |\n|--------|");
dCard3Value=10;
}
else
{
dGraphic3=(" \n|--------|\n|K |\n| |\n| clubs |\n| |\n| K |\n|--------|");
dCard3Value=10;
}
System.out.println("He draws a" +dGraphic3);
dTotal = dTotal+ dCard3Value;
System.out.println("His total is " +dTotal + ".");
}
System.out.println();
if (dTotal<= 21) ///Dealer stays between 16-21
{
System.out.println("Dealer stays.");
System.out.println();
System.out.println("Dealer total is "+ dTotal+ ".");
System.out.println("Your total is "+ pTotal+ ".");
}
System.out.println();
}
///Win or loss shown
if (pTotal> 21)
System.out.println("You busted. The dealer wins.");
else if ((pTotal<= dTotal) && (dTotal<= 21))
System.out.println("The dealer wins.");
else if (dTotal> 21)
{
coins= coins+ (gamble * 2);
System.out.println("The dealer busted. You win! You now have " +coins + " coins.");
}
else
{
coins= coins+ (gamble* 2);
System.out.println("You win " +coins+"! You now have " +coins + " coins.");
}
}
}
Picture of the output