JustAnswer is the largest online question and Expert answer site

Thousands of verified Experts are ready to answer your specific questions 24/7.

 
 
 

Enter Your Question

Subcategory

Select Your Expert
characters left:

2 Programmers are Online Now

 
 
 
  • Legal
    & Tax
  • Cars
    & Vehicles
  • Health
    & Medical
  • Pets
    & Veterinary
  • Home
    & Appliances
  • Computer
    & Education
  • Life
    & Personal
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

How JustAnswer Works

Satisfaction is guaranteed and you pay your Expert only if you are satisfied.

  • Ask Your Question

    Ask Your Question

    Just type your detailed question and click "Get an Answer."

  • Talk With an Expert

    Discuss With an Expert

    In minutes you'll get a response from an Expert. You can always ask follow-up questions.

  • Accept Your Answer

    Accept Your Answer

    Happy with your answer? Just click "Accept" to pay your Expert.

 
 
 

I need help writing a black jack project in java, for BlueJ.

 
 
 

Customer Question

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();

if (suit==1){return "hearts";}

if (suit==2){return "spades";}

if (suit==3){return "clubs";}

if (suit==4){return "diamonds";}

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

import java.util.*;

public class Hand

{

private static String hand_name;

int accountnum;

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

import java.util.*;

public class Player

{

Hand hand = new hand();

public Player()

{

hand = new Hand();

money = new Money();

}

public Hand get_getPlayerHand()

{

return hand;

}

public Money getPlayerMoney()

{

return Money;

}

}

money

/**

* Write a description of class Money here.

*

* @author (your name)

* @version (a version number or a date)

*/

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;

}

}

39852.8351690625

Submitted: 1197 days and 11 hours ago.
Category: Programming
Status: CLOSED
 
 
 
 
 
 

Optional Information



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

 
 
 
 
 
 
Posted by helpdesk 1197 days and 10 hours ago.

Expert's Answer

Hi,
I am attaching the main program with required classes below.
FILES

Hope your problem is solved.Don't forget to give a positive feedback after pressing the accept button.Bonus is appreciated.

 
 
 
 
 
 
1196 days and 5 hours ago.

Customer Reply

It isnt letting me see the program. Do I have to be WinRAR?

 
 
 
 
 
 
Posted by helpdesk 1196 days and 5 hours ago.

Expert's Answer

Yes of course.The files have been attached as a rar format

 
 
 
 
 
 
1196 days and 3 hours ago.

Customer Reply

But its asking me to buy WinRAR archiver. Thats correct right? I have to buy it?

 
 
 
 
 
 
1196 days and 3 hours ago.

Customer Reply

Is there any way you can get it to me without haveing to buy rar or is that the only way?

 
 
 
 
 
 

Accepted Answer

Hi,
Visit the folowing link.You get a 40 day trial version
http://www.download.com/WinRAR/3000-2250_4-10007677.html
Download and use.

Picture
Expert: helpdesk
Pos. Feedback: 100.0 %
Accepts: 28

Computer Software Engineer

Years of experience on C,C++, java,visual basic

 
 
 
 
 
 
1196 days and 2 hours ago.

Customer Reply

Hey thanks so much. The code is great and works well too. Thanks for everything.

 
 
 
 
 
 
Posted by helpdesk 1196 days and 1 hours ago.

Response From Expert

hi,
thanks for the accept and also bonus

 
 
 
 
 
 

Related Programming Questions

 
 
 
Question Date Submitted
 
 
 
 
 
 

Ask Programmer Online Now

2 Programmers are Online Now
Type Your Programming Question Here...
characters left:
Ask Your Question Now