Chat with us, powered by LiveChat It is time to show off all of your incredible talent and all that you have learned by programming a simple card game, we will use the concept of poker, but without actual cards.? Y | Wridemy

It is time to show off all of your incredible talent and all that you have learned by programming a simple card game, we will use the concept of poker, but without actual cards.? Y

It is time to show off all of your incredible talent and all that you have learned by programming a simple card game, we will use the concept of poker, but without actual cards.  You will have three separate, or internal classes that will:

  1. Instantiate a Card
  2. Instantiate a Deck of those Cards, and shuffle and deal them.
  3. Play the game.

In this project you will simulate the playing of a simple card game. You are given a Card and Deck class to use. The Card class should not be changed or renamed, I will use my own Card class when testing your files. 

This assignment should be submitted in two classes; Main+lastName, Deck+lastName, or using internal declared classes, but will not be referenced in this manner henceforth. The first class, Deck, will be a modification of the class I have provided. You will need to implement the shuffleDeck method in order for this class to be usable, which has already been written for you in a method.

The second class, Main, will use the Card class and your modified Deck class to create a shuffled Deck object and deal the two hands. The hands should be dealt in alternating order, starting with the first hand. As the cards are dealt into each hand they should be removed from the deck.

For example, each hand is shown for the following Deck.

seven of spades    <-- Index 0, top card
queen of spades   <-- Index 1, etc.
ten of spades
eight of spades
three of spades
king of hearts
queen of hearts
jack of clubs
four of clubs
eight of clubs
king of diamonds
seven of hearts

Hand 1:  Hand 2:seven of spades queen of spadesten of spades  eight of spadesthree of spades king of heartsqueen of hearts jack of clubsfour of clubs eight of clubs

Each of these cards should be removed from the deck.

After dealing the hand, Main should use the point value attribute of each card to calculate the total point value of each hand. The hand with the highest point value wins. In the case of a draw, the second hand wins. In this game ace = 1, jack = 11, queen = 12, and king = 13. In the deck the card in the first position (index 0) is the top of the deck.

Lastly, Main will declare the winning hand. See the following sample run for the exact format that will be expected.

Sample Run of Main:

Hand 1: Total points 22
three of clubs (point value = 3)
two of clubs (point value = 2)
six of hearts (point value = 6)
ten of hearts (point value = 10)
ace of spades (point value = 1)

Hand 2: Total points 27
four of spades (point value = 4)
ten of clubs (point value = 10)
three of diamonds (point value = 3)
eight of diamonds (point value = 8)
two of hearts (point value = 2)

Hand 2 wins

Play again (y/n)?

To plan for the program, you should review the given classes. Knowing which methods are available to you will be very helpful in designing your game. Then, you should plan the algorithms that you will design.

Use the following table to plan your program.

Card/Deck Methods & VariablesMain

Card – Methods & Variables

  • String suit, String rank, int pointValue
  • public Card(String cardRank, String cardSuit, int cardPointValue)
  • public String suit()
  • public String rank()
  • public int getPointValue()
  • public boolean matches(Card otherCard)
  • public String toString(); use to print each card with a for each

Deck – Methods & Variables

  • private ArrayList<Card> deck;
  • constructor method; instantiate deck ArrayList object, populate elements with cards by calling initialization method, and shuffle it by calling shuffleDeck() (written for you).
  • method to initialize the deck with 52 cards and set their point values; Ace of Clubs through King of Spades. 
  • method to return the top card from the deck and remove it from the stack; return type should match what you are returning.

Main.main

  • instantiate a new Deck object based on Card element types
  • establish two arrays, one for each hand to be dealt
  • deal 5 cards to each hand calling the getTopCard() method from Deck{}
  • total up the values for each hand using getPointValue() from Card{}
  • display the cards and their point values for each hand
  • determine the winning hand and display

You do NOT need to hand in Card, nor customize the class or the instantiation usage of Card in Deck or Main! But you still need to change Deck and Main to include your last name.

PLAGIARISM will earn a ZERO!  Copying someone else's code online, or another student is also considered plagiarism

/* The second class, Main, will use the Card class and your modified Deck class to create a shuffled Deck object and deal the two hands. The hands should be dealt in alternating order, starting with the first hand. As the cards are dealt into each hand they should be removed from the deck. For example, each hand is shown for the following Deck. seven of spades <—- Index 0, top card queen of spades <—- Index 1, etc. ten of spades eight of spades three of spades king of hearts queen of hearts jack of clubs four of clubs eight of clubs king of diamonds seven of hearts Hand 1: Hand 2: seven of spades queen of spades ten of spades eight of spades three of spades king of hearts queen of hearts jack of clubs four of clubs eight of clubs Also, all of these cards should be removed from the deck After dealing the hand, Main should use the point value of each card to calculate the total point value of each hand. The hand with the highest point value wins. In the case of a draw, the second hand wins. In this game ace = 1, jack = 11, queen = 12, and king = 13. In the deck the card in the first position (index 0) is the top of the deck. Lastly, Main will declare the winning hand. See the following sample run of Main for the exact format that will be expected by the code-runner. Sample Run of Main: Hand 1: total points 22 three of clubs (point value = 3) two of clubs (point value = 2) six of hearts (point value = 6) ten of hearts (point value = 10) ace of spades (point value = 1) Hand 2: total points 27 four of spades (point value = 4) ten of clubs (point value = 10) three of diamonds (point value = 3) eight of diamonds (point value = 8) two of hearts (point value = 2) Hand 2 wins */ import java.io.IOException; import java.util.ArrayList; public class Main{ public static void main(String str[]) throws IOException { }

,

/* * Shuffle Deck Class * A class which represents a Deck of cards. For this assignment, you will need to implement the method shuffleDeck, * which appears at the bottom of this class. */ import java.util.ArrayList; public class Deck { /* Your code goes here */ } //SHUFFLE **************************** DO NOT EDIT BELOW!********************************** //You will need to implement the shuffleDeck method in order for this class to be accepted. public ArrayList <Card> shuffleDeck () { ArrayList <Card> t = new ArrayList <Card> (); int i = 0; int n [] = new int [52]; for (int j = 0; j < 52; j++){ i = (int)(Math.random()*52); while (n[i] != 0) i = (int)(Math.random()*52); n[i] = 1; t.add(deck.get(i)); } return t; } }

,

/* * Shuffle Deck Class * A class which represents a single playing card, Card. * Use this class to test the methods in your Deck and Main classes. DO NOT EDIT! */ public class Card { /** * String value that holds the suit of the card */ private String suit; /** * String value that holds the rank of the card */ private String rank; /** * int value that holds the point value. */ private int pointValue; /** * Creates a new "Card" instance. * * @param cardRank a "String" value containing the rank of the card * @param cardSuit a "String" value containing the suit of the card * @param cardPointValue an "int" value containing the point value of the card */ public Card(String cardRank, String cardSuit, int cardPointValue) { //initializes a new Card with the given rank, suit, and point value rank = cardRank; suit = cardSuit; pointValue = cardPointValue; } /** * Accesses this "Card's" suit. * @return this "Card's" suit. */ public String getSuit() { return suit; } /** * Accesses this "Card's" rank. * @return this "Card's" rank. */ public String getRank() { return rank; } /** * Accesses this "Card's" point value. * @return this "Card's" point value. */ public int getPointValue() { return pointValue; } /** Compare this card with the argument. * @param otherCard the other card to compare to this * @return true if the rank, suit, and point value of this card are equal to those of the argument; * false otherwise. */ public boolean matches(Card otherCard) { return otherCard.getSuit().equals(this.getSuit()) && otherCard.getRank().equals(this.getRank()) && otherCard.getPointValue() == this.getPointValue(); } /** * Converts the rank, suit, and point value into a string in the format * "[Rank] of [Suit] (point value = [PointValue])". * This provides a useful way of printing the contents * of a "Deck" in an easily readable format or performing * other similar functions. * * @return a "String" containing the rank, suit and point value of the card. */ @Override public String toString() { return rank + " of " + suit + " (point value = " + pointValue + ")"; } }

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Wridemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order

Related Tags

Academic APA Writing College Course Discussion Management English Finance General Graduate History Information Justify Literature MLA