Thousands of verified Experts are ready to answer your specific questions 24/7.
Satisfaction is guaranteed and you pay your Expert only if you are satisfied.
Just type your detailed question and click "Get an Answer."
In minutes you'll get a response from an Expert. You can always ask follow-up questions.
Happy with your answer? Just click "Accept" to pay your Expert.
I need help writing a black jack project in java, for BlueJ. Here are the instructions and some of the code that i have written already:
instructions:
Your program should include at least the following classes and methods
1. Hand class
- methods to access Card data as integer and String
2. Deck class
- array of 52 cards
- method to shuffle deck
- method to deal a card
3. Hand class
- ArrayList of Cards
- method to add a Card to the Hand
- method to read Hand as a String
- method to calculate and return value of hand (remember: aces can be 1 or 11)
4. Money class
- keeps a running balance of the money
- methods to win and lose bets
- method to return the balance
5. Dealer class
- static methods and static field
- methods to get bets, deal hands, players and dealers turns, comparing the hands
6. Main
Basic gameplay should involve
- a player makes a bet
- a player gets dealt two cards, and sees one of the dealer's cards
- the player can stay or hit up to 21; if they go above 21,they automatically lose
- the dealer automatically hits until 17 or higher; if they go above 21, they automatically lose
- if both hands are 21 or below, the highest hand wins (your choice what to do on a tie)
- player wins or loses based on the hand analysis
Code that I have written:
card
/**
* Write a description of class card here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class card
{
private int suit;
private int number;
public card( int suit, int number)
this. suit = suit;
this. number = number;
}
public int getNumber()
return this. number;
public int getSuit()
return this. suit;
public String getSuitAsString()
if (suit==1){return "hearts";}
if (suit==2){return "spades";}
if (suit==3){return "clubs";}
if (suit==4){return "diamonds";}
else {return "";}
public String getcardasString()
String cardAsString="";
if (number ==2){cardAsString= "two";}
if (number ==3){cardAsString= "three";}
if (number ==4){cardAsString= "four";}
if (number ==5){cardAsString= "five";}
if (number ==6){cardAsString= "six";}
if (number ==7){cardAsString= "seven";}
if (number ==8){cardAsString= "eight";}
if (number ==9){cardAsString= "nine";}
if (number ==10){cardAsString= "ten";}
if (number ==11){cardAsString= "jack ";}
if (number ==12){cardAsString= "queen";}
if (number ==13){cardAsString= "king";}
if (number ==14){cardAsString= "ace";}
cardAsString=cardAsString+" of ";
getSuitAsString();
return cardAsString;
deck
import java.util.*;
public class Deck
ArrayList <card>deck;
private int cardsUsed;
private final static int cardsInDeck = 52;
private final static int suitCount = 4;
private final static int numberCount = 13;
int accountnum;
public Deck ()
int CardCounter = 0;
deck = new ArrayList<card>();
for (int i = 0; i< suitCount;i++){
for (int j=1; j<=numberCount;j++){
{deck.add(new card(i,j));}
hand
public class Hand
private static String hand_name;
card card;
ArrayList<card> hand;
Random genorator = new Random();
int blackJackValue = 0;
public void hand ()
hand = new ArrayList<card>();
public void addcard(card card)
hand.add(card);
public int getBlackJackValue()
for (int i=0; i<=hand.size (); i++)
blackJackValue += hand.get (i). getNumber();
return blackJackValue;
public ArrayList getdeck()
return hand;
player
public class Player
Hand hand = new hand();
public Player()
hand = new Hand();
money = new Money();
public Hand get_getPlayerHand()
public Money getPlayerMoney()
return Money;
money
* Write a description of class Money here.
public class Money
private int balance;
private int betAmount;
public void money()
balance = 100;
public void lose(int betAmount)
balance = balance-betAmount;
public void win(int betAmount)
balance = balance+betAmount;
Already Tried: instructions: Your program should include at least the following classes and methods 1. Hand class - methods to access Card data as integer and String 2. Deck class - array of 52 cards - method to shuffle deck - method to deal a card 3. Hand class - ArrayList of Cards - method to add a Card to the Hand - method to read Hand as a String - method to calculate and return value of hand (remember: aces can be 1 or 11) 4. Money class - keeps a running balance of the money - methods to win and lose bets - method to return the balance 5. Dealer class - static methods and static field - methods to get bets, deal hands, players and dealers turns, comparing the hands 6. Main Basic gameplay should involve - a player makes a bet - a player gets dealt two cards, and sees one of the dealer's cards - the player can stay or hit up to 21; if they go above 21,they automatically lose - the dealer automatically hits until 17 or higher; if they go above 21, they automatically lose - if both hands are 21 or below, the highest hand wins (your choice what to do on a tie) - player wins or loses based on the hand analysis Program that i have written so far: card /** * Write a description of class card here. * * @author (your name) * @version (a version number or a date) */ public class card { private int suit; private int number; public card( int suit, int number) { this. suit = suit; this. number = number; } public int getNumber() { return this. number; } public int getSuit() { return this. suit; } public String getSuitAsString() { if (suit==1){return "hearts";} if (suit==2){return "spades";} if (suit==3){return "clubs";} if (s
Hi,I am attaching the main program with required classes below.FILESHope your problem is solved.Don't forget to give a positive feedback after pressing the accept button.Bonus is appreciated.
It isnt letting me see the program. Do I have to be WinRAR?
Yes of course.The files have been attached as a rar format
But its asking me to buy WinRAR archiver. Thats correct right? I have to buy it?
Is there any way you can get it to me without haveing to buy rar or is that the only way?
Hi,Visit the folowing link.You get a 40 day trial versionhttp://www.download.com/WinRAR/3000-2250_4-10007677.htmlDownload and use.
Computer Software Engineer
Years of experience on C,C++, java,visual basic
Hey thanks so much. The code is great and works well too. Thanks for everything.
hi,thanks for the accept and also bonus