Question: * * * In java * * * how do I improve this game? I can't figure out how to draw and read the cards

***In java*** how do I improve this game? I can't figure out how to draw and read the cards correctly: import java.util.*;
import java.util.ArrayList;
public class BlackJack{
public static void main(String[] args){int bets;
int bank =500;
int hit;
int playAgain =0;
Deck gameDeck = new Deck();
Card gameCard = new Card();
int drawnCards =0;
int dealerTotal =0;
ArrayList bjDeck = new ArrayList<>();
Scanner input = new Scanner(System.in);
do{
System.out.println("Welcome to Blackjack you have $"+ bank);
System.out.println("Place your bets");
bets = input.nextInt();
System.out.println("Here are your 2 cards");
gameDeck.drawCard();
bjDeck.add(gameDeck);
gameDeck.drawCard();
bjDeck.add(gameDeck);
System.out.println(bjDeck.get(0)+""+ bjDeck.get(1));
System.out.println("Total is: "+ "add drawn cards");
System.out.println("Do you want a hit? 1= yes 2= no");
hit = input.nextInt();
if(hit ==1){
//draw another card and add to previous cards
//draw 2 dealer cards from the same deck and total them
System.out.println("Dealer Total "+ "total dealer cards");
if(dealerTotal <=21 && drawnCards >21){
System.out.println("Dealer Wins");
bank = bank - bets;
}
else{
System.out.println("Dealer Busted");
bank = bank + bets;
}
}
else if(hit ==2){
//draw 2 dealer cards from the same deck and total them
System.out.println("Dealer Total "+ "total dealer cards");
if(dealerTotal <=21 && dealerTotal > drawnCards){
System.out.println("Dealer Wins");
bank = bank - bets;
}
else{
System.out.println("Dealer Busted");
bank = bank + bets;
}
}
System.out.println("Your Bank: $"+ bank);
System.out.println("Do you want to play again? 1= yes 2= no");
playAgain = input.nextInt();
}while(playAgain !=2);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!