Create a Java text-based simulation that plays baccarat between
two players. In baccarat, there is a banker and there is a player.
Two cards are dealt to the banker and two cards to the player. Both
cards in each hand are added together, and the objective (player)
is to draw a two or three-card hand that totals closer to 9 than
the banker. In baccarat, the card values are as follows:
• 2–9 are worth face value
• 10, J, Q, K are worth 0
• A is worth 1
The suits are the standard values. Players calculate their score by
taking the sum of all cards modulo 10. In other words, after adding
the value of the cards, the tens digit is ignored. So, for example,
a hand consisting of 3 and 4 is worth 7. A hand consisting of 7 and
8 is worth 5 (15 % 10). A hand consisting of 5 and 5 is worth 0 (10
% 10). The highest point total that can be achieved is 9. After the
player and the banker are dealt two cards each, an additional card
is drawn depending on the following conditions:
• If either the player’s hand or the banker’s hand totals 8 or 9,
both automatically stand, and a winner is determined.
• If the player’s hand totals 6 or 7, the player stands.
• If the player stands, the banker must draw a card if his/her hand
totals 5 or less.
• If the player’s hand is 5 or less, the player must draw another
card.
• If the player draws a third card, then the banker must draw a
third card if:
• Banker’s hand totals 0, 1, or 2.
• Banker’s hand totals 3 and the player’s total after drawing the
third card is not 8.
• Banker’s hand totals 4 and the player’s total after drawing the
third card is 2-7.
• Banker’s hand totals 5 and the player’s total after drawing the
third card is 4-7.
• Banker’s hand totals 6 and the player’s total after drawing the
third card is 6-7.
• If the player draws a third card and the banker’s hand totals 7,
then the banker must stand with his two cards.
• Once the final cards are dealt, the player with the total closest
points to 9 wins.
Betting:
• If a third card needs to be dealt to the player, the banker or
both, the player has an opportunity to make a bet greater than 0
and less than or equal to his/her current balance.
• If the player loses the hand, the amount he/she bet gets deducted
from the total. If the player wins the hand, he/she wins the bet
amount. In the case of a tie, the amount of the bet is neither
added nor deducted from the total.
• The player will begin with $500 and the default bet is $50. The
only time the player can make a bet is if he/she and/or the banker
must draw a card, at which point the player can bet any amount
greater than 0 and less than or equal to the total. The game ends
when the player loses all of his/her money or decides to
quit.
Finally ask the user to play again. Error check values. Need to run
in Java Eclipse.
public class Card
{
private String suit;
private int value;
/**
* Constructor for objects of class Card with parameters suit and value.
*/
public Card(String suit, int value)
{
this.suit = suit;
this.value = value;
}
/**
* Accessor method for the suit of the card.
* @return suit.
*/
public String getSuit()
{
return suit;
}
public int getValue()
{
return value;
}
public String toString()
{
return value + " of " + suit;
}
public int compareTo(java.lang.Object c)
{
return this.value - ((Card) c).value;
}
}
/////////
public class Deck
{
public ArrayList<Card> deck; // this ArrayList will be storing cards into the deck
private int currentCardIndex;
/**
* Constructor for objects of class Deck
*/
public Deck()
{
String suits[] = {"Hearts", "Diamonds", "Clubs", "Spades" };
deck = new ArrayList<>();
currentCardIndex = 0;
for( int count = 0; count < 52; count++)
{
deck.add(new Card(suits[count / 13], 1 + count % 3));
}
java.util.Collections.shuffle(deck);
}
public int getcurrentCardIndex()
{
return currentCardIndex;
}
public Card deal()
{
if(currentCardIndex >= 46)
{
java.util.Collections.shuffle(deck);
currentCardIndex = 0;
}
return deck.get(currentCardIndex++);
}
}
/////////////
public class Hand
{
private ArrayList<Card> hand;
/**
* Constructor for objects of class BaccaratGame
*/
public Hand()
{
}
public int getSum()
{
int sum = 0;
for(Card c: hand)
{
if(sum >= 10)
{
sum += c.getValue()%10;
}
else
{
sum+= c.getValue();
}
}
return sum;
}
public void addCard(Card c)
{
if(hand.size() < 3)
{
hand.add(c);
}
else
{
System.out.println("3 card max");
}
}
public int getNumOfCards()
{
return hand.size();
}
public String toString()
{
String handString = "";
for(Card c : hand)
{
handString += c.toString();
}
return handString;
}
}
////////
public class BaccaratGame
{
// instance variables - replace the example below with your own
public BaccaratGame()
{
}
public void outcome()
{
//include method to determine outcome(player,dealer,tie)
Hand player = new Hand();
Hand banker = new Hand();
if (player.getSum() > banker.getSum()){
System.out.println("player wins");
}
else{
System.out.println("Banker wins");
}
if(player.getSum() == banker.getSum()){
System.out.println("tie");
}
}
}
///////////
public class Simulation
{
/**
* Constructor for objects of class Simulation
*/
public static void Simulation()
{
int bet = 10;
int pot = 10000;
Deck d = new Deck();
Hand player = new Hand();
Hand banker = new Hand();
player.addCard(d.deal());
}
public static void main(String[] args){
}
}
Create a Java text-based simulation that plays baccarat between two players. In baccarat, there i...
You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. You may complete this project individually or in a group of no more than 2 other people. Requirements do not change if you choose to complete the project individually or as part of a group. Customer-specific requirements You can create...
Using Java You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. Customer-specific requirements You can create new customers All new customers have a new customerID assigned to them, starting with 1 for the first, 2 for the second, 3 for the third, ect. New customers have names and monetary...
Create a simplified Blackjack game using the Deck and Card classes (download the attached files to start). There is also a "TestCard" class that creates a Deck and runs some simple code. You may choose to use this file to help you get started with your game program. 1) Deal 2 cards to the "player" and 2 cards to the "dealer". Print both the player's cards, print one of the dealer's cards. Print the total value of the player's hand. 2) Ask...
Need a blackjack code for my assignment its due in 3 hours: it has to include classes and object C++. Create a fully functioning Blackjack game in three separate phases. A text based version with no graphics, a text based object oriented version and lastly an object oriented 2D graphical version. Credits (money) is kept track of throughout the game by placing a number next to the player name. Everything shown to the user will be in plain text. No...
How do I start this c++ code homework? Write a code in C++ for a BlackJack card game using the following simplified rules: Each card has a numerical value. Numbered cards are counted at their face value (two counts as 2 points, three, 3 points, and so on) An Ace count as either 1 point or 11 points (whichever suits the player best) Jack, queen and king count 10 points each The player will compete against the computer which represents...
You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...
"Blackjack 40" my teacher created this assignment and I need help. He is using c++ and has provided this template: Further instructions are below the template! #include <iostream> #include <cmath> #include <cstdlib> using namespace std; //Will return a number from 1 to 13, representing the face of a card int draw_card() { return rand() % 13 + 1; } int main() { const int BET = 10; //This will allow you to control chance, to make testing easier cout <<...
There are 2 cards, an A and a 2. Two players I and II Both players put $1 in the pot. Player I deals a card and player II looks at it. If the card is an A then player II must say it, but if the card is a 2, player II can choose either A or 2 to say. If player II says 2, he looses and his money. If player II says A, then no matter what...
the card game Acey Deucey, which is also known by several other names. In general, the game is played with three or more people that continue to gamble for a pot of money. The pot grows and shrinks depending on how much General description of the game ● Two cards are dealt face up to a player from a shuffled deck of cards. ○ If the face of each card is the same then the player adds $1 into the...
Using Dr Java Objective: Create a game of video poker with a graphical user interface (GUI). The player should start with $100, and then the system deals out 5 playing cards. After the player sees the cards they are then asked to wager $10, $20, $50, or $100. Next the user picks which cards they wish to throw away, and then the system deals more cards in their place. Once this has concluded money are awarded by these criteria: Nothing...