Answered step by step
Verified Expert Solution
Question
1 Approved Answer
* * * HELP in JAVA * * * I feel like I ' m so close to getting it to work but I don't
HELP in JAVA I feel like Im so close to getting it to work but I don't know what to do with my objects to make it effective:Write a BlackJack program that plays a game of BlackJack.
The program must draw a card randomly from a standard deck of cards.
Your program must not print the same card twice until the deck runs out.
Your program must shuffle the deck when if runs out of cards.
All cards should be added back to the deck when shuffle is called.
Your program should produce different output every time it runs Based on randomly selecting cards
For simplicity, you can consider the BlackJack value of an Ace to be
This is what I have so far:
@author newToLife
public class Card
Use these class diagrams to create your objects.
private int value;
private String suit;
private String Color;
private String face;
public Card
public Cardint value, String suit
this.value value;
this.suit suit;
@Override
public String toString
return face of suit;
public String getColor
return Color;
public String getFace
return face;
public int getValue
return value;
public int getBjValue
int BJValue;
ifvalue && value
BJValue value;
return BJValue;
else
BJValue ;
return BJValue;
public String getSuit
return suit;
next file
public class Deck
private ArrayList cards new ArrayList;
private int deckSize ;
public Deck
loadCards;
private void loadCards
for int value ; value ; value
forString suit : new Stringhearts"diamonds","clubs", "spades"
Card card new Cardvalue suit;
cards.addcard;
shuffle;
public Card drawCard
if deckSize
loadCards;
deckSize;
return cards.removedeckSize;
public int getDeckSize
return deckSize;
public void shuffle
java.util.Collections.shufflecards;
deckSize cards.size;
next file
import java.util.;
import java.util.ArrayList;
public class BlackJack int bets;
int bank ;
int hit;
int playAgain ;
Deck gameDeck new Deck;
Card gameCard new Card;
int drawnCards ;
int dealerTotal ;
ArrayList bjDeck new ArrayList;
Scanner input new ScannerSystemin;
do
System.out.printlnWelcome to Blackjack you have $ bank;
System.out.printlnPlace your bets";
bets input.nextInt;
System.out.printlnHere are your cards";
gameDeck.drawCard;
bjDeck.addgameDeck;
gameDeck.drawCard;
bjDeck.addgameDeck;
System.out.printlnbjDeckget bjDeck.get;
System.out.printlnTotal is: "add drawn cards";
System.out.printlnDo you want a hit? yes no;
hit input.nextInt;
ifhit
draw another card and add to previous cards
draw dealer cards from the same deck and total them
System.out.printlnDealer Total "total dealer cards";
ifdealerTotal && drawnCards
System.out.printlnDealer Wins";
bank bank bets;
else
System.out.printlnDealer Busted";
bank bank bets;
else ifhit
draw dealer cards from the same deck and total them
System.out.printlnDealer Total "total dealer cards";
ifdealerTotal && dealerTotal drawnCards
System.out.printlnDealer Wins";
bank bank bets;
else
System.out.printlnDealer Busted";
bank bank bets;
System.out.printlnYour Bank: $ bank;
System.out.prin
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started