Question

the card game Acey Deucey, which is also known by several other names. In general, the...

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 pot and the game advances to the next player (i.e., add $1 into the pot and move on) ● The player bets a dollar amount between nothing (forfeits the round) and the amount of money in the pot based on if they think the next card drawn will fall in the range of the two cards from the previous step. ● A third card is dealt face up to the player 2/4 V1.0 ○ If the card is within the range, but not on the edge of the two face up cards, then the player wins and they receive the amount of money they bet (e.g., the player bet $2 in step two then they get $2 from the pot) ○ If the card is on the edge then they put double their bet into the pot ○ If the card is outside of the range then they put their bet into the pot ● Repeat until there is no more money in the pot. MINIMUM Project Requirements ● Before the game: There must be a minimum of four players to be able to play the game. There is no limit to number of players in the game. ○ Ask the users to enter their name and the amount of money they have available to play. ○ After the players have been created, add $5 from each of the players into the pot ○ Bonus: Use a linked list to keep track of all of the players. typedef struct player_s { char name[100]; float bank_roll; struct player_s *listp; } player; ● You must then shuffle the deck (52 cards), using the following algorithm: ○ For each card in the deck, get a random number in the range of 0 to 50 to be used as the index of the element to swap that card with, i.e. if deck[0] holds the Jack of clubs (J♣) and the random number generated was 24, and deck[24] holds the 9 of diamonds (9♦), then after the first swap, deck[0] would hold the 9 of diamonds (9♦) and deck[24] would hold the Jack of clubs (J♣). You would then proceed to deck[1], find a random index of a card to swap with, and swap those cards, etc. ○ Repeat step (a) at least 500 times. ○ Note: You must seed the random number generator with a call to time() with srand(). [see sec 2.22 Random numbers in your Zyante book] At the demo time, you will be asked to print the deck after the shuffle is done. ● Your deck of cards must be created using a linked list. There will be ZERO credit given to a final project that does not use a linked list. We suggest the data structure shown below. Each card consists of a suit [clubs (♣),spades (♠),hearts (♥), or diamonds (♦)) a face (2 – 10, Jacks (J), Queens (Q), Kings (K), and Aces (A)) 3/4 V1.0 typedef struct card_s { char suit; int face; struct card_s *listp; } card; THE GAME OF ACEY DEUCEY STARTS HERE ● For the first player, deal two cards face up to the player from the shuffled deck. ○ If the face of each card is the same then the player adds $1 into the pot and the game advances to the next player (i.e., add $1 into the pot and move on) ● If the two cards that were dealt to the player are not the same face then she/he bets a dollar amount between nothing (forfeits the round) and the amount of money in the pot based on if they think the next card drawn will fall in the range of the two cards from the previous step. ● A third card is dealt face up to the player ○ If the card is within the range, but not on the edge of the range, then the player wins and the receive the amount of money they bet (e.g., bet $2 in step two then they get $2 from the pot) ○ If the card is on the edge then they put double their bet into the pot. If they do not have enough in their bank account to cover double the bet then their entire bank account is deposited into the pot and they are no longer eligible to play the game. ○ If the card is outside of the range then they put their bet into the pot. ● Move on to the next player and repeat until there is no more money in the pot. ● NOTE: Players are only allowed to bet a maximum of $1 during the first round. After the first round there is no limit on the bet size. THINGS TO KEEP IN MIND ● You must check to make sure that the player has enough money to make the bet they would like to place. If they do not have the money then your code must ask the user to enter a bet that they can afford. If a player loses all of their money then they can no longer play the game. ● During the game, if there are not enough cards to play a round then the deck of cards needs to be re-shuffled before the next player is allowed to play her/his turn. Bonus Points (see rubric) ● (+1pt) Use a linked list to keep track of the players since we do not know the number of players when our program begins. We suggest that the linked list to keep track of all of the players look like: 4/4 V1.0 typedef struct player_s { char name[100]; float bank_roll; struct player_s *listp; } player; ● Graphics: Add graphics to your game. (+2.5pt) If you can print using ♣, ♠, ♥, ♦ (+2.5pt) If you can make the card for each card look like (at least) ------- ------- |9♥ | |K♣ | | | | | | | | | | 9♥| | K♣| ------- ------- ● (8pt) ○ (4pt) Add the ability to read/write game statistics to a text file. For example, write a text file that has a row for each of the players and the amount of money they have in their bank account. ○ (4pt) Allow an option to allow the users to read one of these files instead of having the user enter them manually through the command line.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Creation of class 'Decky'

//variable 'i' is used as index for card selection.

//Procedue using Random method is also used, for each of the sign in the cards.

//importing java packages

package javacards;
import java.util.Random;
public class Decky {
private Card[] cards;
int i;

Decky()
{
i=51;
cards = new Card[52];
int x=0;
for (int a=0; a<=3; a++)
{
for (int b=0; b<=12; b++)
{
cards[x] = new Card(a,b);
x++;
}
}
}

public Card drawFromDeck()
{
Random generator = new Random(); // Random generator used.
int index=0;

do {
index = generator.nextInt( 52 );
} while (cards[index] == null);

i--;
Card temp = cards[index];
cards[index]= null;
return temp;
}

public int getTotalCards()
{
return i;
}
}

==========================================================================================

Cards drawn in random order -

package javacards;
public class Main {

public static void main(String[] args)
{
Decky deck1 = new Decky();
Card C;

System.out.println( deck1.getTotalCards() ); // printing total number of cards

while (deck1.getTotalCards()!= 0 ) // chekcing the total with the exisitng deck of cards
{
C = deck1.drawFromDeck();
System.out.println( C.toString() );
}
}

==========================================================================================

//With a random index 'i' -

package javacards;
import java.util.Random;
public class Decky {
private Card[] cards;
int i;

Decky()
{
i=51;
cards = new Card[52];
int x=0;
for (int a=0; a<=3; a++)
{
for (int b=0; b<=12; b++)
{
cards[x] = new Card(a,b);
x++;
}
}
}

public Card drawFromDeck()
{
Random generator = new Random();
int index=0;

index = generator.nextInt( i );

Card temp = cards[index]; // swapping after checking with the index.
cards[index]=cards[i];
cards[i]=null;
i--;
return temp;
}
}

=============================================================

Creation of Array List -

package javacards;
import java.util.Random;import java.util.ArrayList;
public class Decky {
private ArrayList<card /> cards;

Decky()
{
cards = new ArrayList<card />();
for (int a=0; a<=3; a++)
{
for (int b=0; b<=12; b++)
{
cards.add( new Card(a,b) ); // adding cards to list
}
}
}

public Card drawFromDeck()
{
Random generator = new Random();
int index= generator.nextInt( cards.size() ); // adding to the deck of cards
return cards.remove(index); // removing the count, once the cards are drawn from the deck of cards.
}

public int getTotalCards()
{
return cards.size(); // remaining size of the cards.
}
}
===================================================
Shuffling cards before dealing -

package javacards;
import java.util.Random;import java.util.ArrayList;
public class Decky {
private ArrayList<card /> cards;

Decky()
{
cards = new ArrayList<card />();
int index_1, index_2;
Random generator = new Random();
Card temp;

for (int a=0; a<=3; a++)
{
for (int b=0; b<=12; b++)
{
cards.add( new Card(a,b) );
}
}


for (int i=0; i<100; i++)
{
index_1 = generator.nextInt( cards.size() - 1 );
index_2 = generator.nextInt( cards.size() - 1 );

temp = (Card) cards.get( index_2 );
cards.set( index_2 , cards.get( index_1 ) );
cards.set( index_1, temp );
}
}

// Mehtods to 'remove' the card from the deck and return total count as stated above too ...

public Card drawFromDeck()

{   
return cards.remove( 0 );
}

public int getTotalCards()
{
return cards.size();
}
}

Add a comment
Know the answer?
Add Answer to:
the card game Acey Deucey, which is also known by several other names. In general, the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2 A Game of UNO You are to develop an interactive game of UNO between a...

    2 A Game of UNO You are to develop an interactive game of UNO between a number of players. The gameplay for UNO is described at https://www.unorules.com/. Your program should operate as follows. 2.1 Setup 1. UNO cards are represented as variables of the following type: typedef struct card_s { char suit[7]; int value; char action[15]; struct card_s *pt; } card; You are allowed to add attributes to this definition, but not to remove any. You can represent colors by...

  • Using Python 3.5.2 and IDLE Write the code for a modified game of the card game...

    Using Python 3.5.2 and IDLE Write the code for a modified game of the card game crazy eights (much like a game of UNO, where the card played is now on top of the deck and its number or face value is now what is playable for the next player). Write the code to be a 2 player game with any 8 card being able to input a new face value to play on the discard pile. Rules: Use a...

  • Please to indent and follow structure!!!!! Assignment 3 - The card game: War Due Date: June...

    Please to indent and follow structure!!!!! Assignment 3 - The card game: War Due Date: June 9th, 2018 @ 23:55 Percentage overall grade: 5% Penalties: No late assignments allowed Maximum Marks: 10 Pedagogical Goal: Refresher of Python and hands-on experience with algorithm coding, input validation, exceptions, file reading, Queues, and data structures with encapsulation. The card game War is a card game that is played with a deck of 52 cards. The goal is to be the first player to...

  • Program 4: C++ The Game of War The game of war is a card game played by children and budding comp...

    Program 4: C++ The Game of War The game of war is a card game played by children and budding computer scientists. From Wikipedia: The objective of the game is to win all cards [Source: Wikipedia]. There are different interpretations on how to play The Game of War, so we will specify our SMU rules below: 1) 52 cards are shuffled and split evenly amongst two players (26 each) a. The 26 cards are placed into a “to play” pile...

  • Using C++: 1. Array and Struct in Card applications: In card game design, card suit and...

    Using C++: 1. Array and Struct in Card applications: In card game design, card suit and face values can be defined with enumeration values. Declare suit values - – hearts, clubs, diamonds, spades using enum, declare face values of 2 – 10, Jack, Queen, King, Ace using enum Declare a structure called Card, and it includes two data members, whose data types are the above two defined enumerations suit and face typedef an array called Deck, and it includes all...

  • NEED HELP TO CREATE A BLACKJACK GAME WITH THE UML DIAGRAM AND PROBLEM SOLVING TO GET...

    NEED HELP TO CREATE A BLACKJACK GAME WITH THE UML DIAGRAM AND PROBLEM SOLVING TO GET CODE TO RUN!! THANKS Extend the DeckofCards and the Card class in the book to implement a card game application such as BlackJack, Texas poker or others. Your game should support multiple players (up to 5 for BlackJack). You must build your game based on the Cards and DeckofCards class from the book. You need to implement the logic of the game. You can...

  • C++ program This program involves writing a VERY simplified version of the card game War. You...

    C++ program This program involves writing a VERY simplified version of the card game War. You may know this game or not but my rules are these 1. Split the deck between player1 and player2. Only the face values matter (2-14) and not the suits 2. Each player puts a card down on the table. The higher face value wins that hand. If the card values match, you will simply indicate tie and neither player wins.The original rules would require...

  • Using C++ Create a Blackjack program with the following features: Single player game against the dealer....

    Using C++ Create a Blackjack program with the following features: Single player game against the dealer. Numbered cards count as the number they represent (example: 2 of any suit counts as 2) except the Aces which can count as either 1 or 11, at the discretion of the player holding the card. Face cards count as 10. Player starts with $500. Player places bet before being dealt a card in a new game. New game: Deal 2 cards to each...

  • C++ programming: Card game Can same one help me out with a example finsih and working...

    C++ programming: Card game Can same one help me out with a example finsih and working programm ? Program the basis for a card game (as a class card game): ● A card is represented by its suit/symbol (clubs, spades, hearts, diamonds) and a value (seven, eight, nine, ten, jack, queen, king, ace). ● A deck of cards consists of a pile of 32 cards that are completely connected to four players are distributed. ● Implement the following menu: ===...

  • 2. You are playing a game where you chose a card at random from a standard...

    2. You are playing a game where you chose a card at random from a standard deck of 52 cards. If the card chosen is a face card then you win $3. If the card is not a face card then you pay $1. There are 12 face cards in the deck. (a) How much money would you expect to win or lose each time you play the game? (b) If you wanted to make the answer to part a)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT