Question: Hi i neeeeeeeed heeeeelllp to write a program in java using stack for a deck class for a poker game and i need to create
Hi i neeeeeeeed heeeeelllp to write a program in java using stack for a deck class for a poker game and i need to create a card and hand class but i dont know how to accomplish this i really am stuck can you please help me i would be appreciate it here is the description of the poker game
Poker is an interactive card game having one or more players, one of which may be the computer. There are many variations of the game, however, in this instance, each player is dealt out five (5) cards face up from a deck of shuffled cards. Each player can then decide to discard up to three (3) of these cards, which are then replaced from the deck. Each players hand is then evaluated against a the hands of the others to determine if he/she is a winner. In this project, we are only interested in establishing a framework for a deck of cards and the hand held by each player. This framework could be used to implement such a game, but we ARE NOT developing the game. No specific design will be dictated in advance except that there should be Card, Deck, and Hand (player) classes. Any implementation of Deck and Hand must employ the following interfaces:
public interface DeckInterface { Card deal(); boolean isEmpty(); }
public interface HandInterface extends Comparable { void addCard(Card card); // Add a card to hand boolean removeCard(Card card); // Remove this card from hand String toString(); // Return contents of this hand }
The Deck class must employ a stack for its underlying structure. Otherwise, your solution should demonstrate reasonable choices of data structures to implement this game. (Most data structures mimic how we do things manually.) Grading will concentrate on this and not on your ability to make it work. You have complete freedom to implement a tester class or use the one provided below for this project, however, keep in mind that your implementations will be tested using another program. The procedure for testing for the highest hand can be rather complex. For this project, well simplify this to the hand having the greatest number of highest ranking cards. For example, a hand having an Ace beats another having two Kings.
public class Tester { public static void main(String[] args) { Deck deck = new Deck(); System.out.println(deck); Hand player1 = new Hand(); Hand player2 = new Hand(); Card card; Card card1 = null, card3 = null, card4 = null; for (int i=0; i < 5; i++) { card = deck.deal(); if (i==1) card1 = card; // card that will be removed if (i==3) card3 = card; // card that will be removed player1.addCard(card); card = deck.deal(); if (i==4) card4 = card; // card that will be removed player2.addCard(card); } System.out.println(player1); System.out.println(player2); System.out.println(deck); // remove 2nd and 4th cards player1.removeCard(card1); player1.removeCard(card3); System.out.println(player1); player2.removeCard(card4); System.out.println(player2); player1.addCard(deck.deal()); // Add back player1.addCard(deck.deal()); // Add back player2.addCard(deck.deal()); // Add back System.out.println(deck); System.out.println(player1); System.out.println(player2); int winner = player1.compareTo(player2); if (winner == 0) { System.out.println("Tie game"); } else if (winner > 0) { System.out.println("Player1 wins"); } else { System.out.println("Player1 lost"); } } }
import java.util.Stack; import java.util.*;
public class Deck {
public interface DeckInterface { Card deal(); boolean isEmpty(); }
}
public class Card {
public Card(int deal) { // TODO Auto-generated constructor stub }
}
public class Hand { public interface HandInterface extends Comparable
please i really need this done by tomorrow thank you
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
