Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java Poker Simulator: In this assignment, you will implement a simulation of

ID: 3679871 • Letter: I

Question

In Java

Poker Simulator: In this assignment, you will implement a simulation of a popular casino game usually called video poker. The card deck contains 52 cards, 13 of each suit. At the beginning of the game, the deck is shuffled. You need to devise a fair method for shuffling. (It does not have to be efficient.) Then the top five cards of the deck are presented to the player. The player can reject none, some, or all of the cards. The rejected cards are replaced from the top of the deck. Now the hand is score. At the very minimum, your project should have at least a Card class and a driver class. Your program should pronounce it to be one of the following: * No pair - The lowest hand, containing five separate cards that do not match up to create any of the hands below. * One pair - Two cards of the same value, for example two queens. * Two pairs - Two pairs, for example two queens and two 5's. * Three of a kind - Three cards of the same value, for example three queens. * Straight - Five cards with consecutive values, not necessarily of the same suit, such as 4, 5, 6, 7, and 8. The ace can either precede a 2 or follow a king. * Flush - Five cards, not necessarily in order, of the same suit. * Full House - Three of a kind and a pair, for example three queens and two 5's * Four of a Kind - Four cards of the same value, such as four queens * Straight Flush - A straight and a flush: Five cards with consecutive values of the same suit * Royal Flush - The best possible hand in a poker. A 10, jack, queen, king, and ace, all of the same suit. If you are so inclined, you can implement a wager. The player pays a JavaDollar for each game, and wins according to the following payout chart: Hand Payout Royal Flush 250 Straight Flush 50 Four of a Kind 25 Full House 6 Flush 5 Straight 4 Three of a kind 3 Two Pair 2 Pair of Jacks 1 or Better

Need easy basic classes to use

Explanation / Answer

//SimpleCard Class

public class SimpleCard
{

//initializing variables as private
private String rank;
private String suit;

//constructor

public SimpleCard()
{
rank = " ";
suit = " ";
}

public void setSuit(String s)
{
suit = s;
}
public void setRank(String s)
{
rank = s;
}

public SimpleCard(String r, String s)
{
rank = r;
suit = s;
}


public String getSuit()
{
return suit;
}
public String getRank()
{
return rank;
}
public String toString()
{
String str;
str = "Card " + rank + " of " + suit;
return str;
}
public void swapCards(SimpleCard otherCard)
{
SimpleCard temp= new SimpleCard(this.rank, this.suit);

this.rank = otherCard.rank;
this.suit = otherCard.suit;

otherCard.rank = temp.rank;
otherCard.suit = temp.suit;
}

}


//SimpleDeck Class

import java.util.Random;
public class SimpleDeck
{
private SimpleCard[] theDeck;
Random randomNumbers = new Random();
//intilaing constructor with all functions

public SimpleDeck()
{
theDeck = new SimpleCard[52];
initDeck();
setSuits();
setRanks();
shuffle();
}

//creating cards for decks
public void initDeck()
{
for(int i = 0; i < theDeck.length; i++)
theDeck[i] = new SimpleCard();
}
//setting suits

public void setSuits()
{
String[] suitName = {"Hearts", "Spades", "Diamonds", "Clubs"};
for (int i = 0; i < theDeck.length; i++)
{
theDeck[i].setSuit(suitName[i / 13]);
}
}

//giving ranks
public void setRanks()
{
String[] rankName = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
for (int i = 0; i < theDeck.length; i++)
{
theDeck[i].setRank(rankName[i % 13]);
}
}

//printing decks
public void printDeck()
{
for (int i = 0; i < theDeck.length; i++)
{
System.out.println(theDeck[i].getRank() + " of " + theDeck[i].getSuit());
}
}

public void shuffle()
{
for (int i = 0; i < theDeck.length; i++)
{
theDeck[i].swapCards(theDeck[randomNumbers.nextInt(52)]);
}

}

}

//PockerGame Class

public class PokerGame
{
public static void main(String[] args)
{
SimpleDeck gameDeck[] = new SimpleDeck();
String[] hand = new String[5];
System.out.println("Welcome to Video Poker");
System.out.println("Your hand");
int j = 0;
for (int i = 0; i < 5; i++)
{
hand[i] = gameDeck[j];
j++;
}

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote