Using JavaFX, create a GUI based version of the card game Hockey. This version o
ID: 3605313 • Letter: U
Question
Using JavaFX, create a GUI based version of the card game Hockey. This version of the game uses a standard deck of 52 playing cards. Create a game between Human and AI. Base the game off the graph below
Dealing: Start by dealing entire deck of 52 cards (without jokers) to the players - 13 cards each. Players sitting opposite of each other are partners. Once all cards are dealt, the game can begin. Playing once through the deck - four deals of 5 cards each and one of 6 cards each - is known as a "period". After a period is over, the next period begins and players switch as dealers. Three periods constitute a complete game. Like in hockey the player with the most goals after 3 periods win the game.
Scoring: A player scores by matching the card played before them. Example: if a player plays a 7 of hearts and the next player plays any other 7 then that team collects that goal, and clears the cards. Play continues until all the cards have been played. At the end of each period goals are counted and tallied.
Examples: Player A plays a 7, player B plays a 7 (breakaway for B), player A plays a 4, player B plays a 4 (goal for B). Player A plays a 7, B plays a 7 (breakaway for B), A plays a 4, B plays a 5 (breakaway lost), A plays a 9, B plays a 9 (breakaway for B - not a goal), A plays a Jack (breakaway for A), B plays an 8, A plays an 8 (goal for A). A goal itself is not a breakaway. After a goal a new breakaway is needed before a new goal can be scored. However, a breakaway can be created by matching the card used to score a goal.
Stage stage Boxes 22 Player integer score Boolean tum-false Boolean winner false Deck crealeHlands ake TurnO fabstracty Card Hand Human Al String sut String value feld:typ takeTun keum addNew Card Card)Explanation / Answer
java Program :
public class game {
public static void main(String[] args) {
DockOfCards testDeck;
testDeck = new DockOfCards();
int round=1;
System.out.println(" play the simple card game hokey ,");
Scanner reader = new Scanner(System.in); // Reading from System.in
System.out.println("Enter type of player to play: ");
int hand = reader.nextInt();
giveplayerhand(hand)
{
public player accepthand(hand);
}
void startgame()
{
do {
int scoreThisGame; // Score for one game.
scoreThisGame = play(); // Play the game and get the score.
sumOfScores += scoreThisGame;
gamesPlayed++;
System.out.print("Play again? ");
playAgain = TextIO.getlnBoolean();
} while (playAgain);
averageScore = ((double)sumOfScores) / gamesPlayed;
System.out.println();
System.out.println("You played " + gamesPlayed + " games.");
System.out.printf("Your average score was %1.3f. ", averageScore);
}
private static int play() {
DockOfCards deck = new DockOfCards(); // Get a new deck of cards, and
DockOfCards.shuffle(); // Shuffle the deck into a random order before
// starting the game.
correctGuesses = 0;
currentCard = DockOfCards.dealCard();
}
player.taketurn(testDeck, round);
} // end of while loop
void endgame()
{
System.out.println();
System.out.println("The game is over.");
System.out.println("You made " + correctGuesses
+ " correct predictions.");
System.out.println();
} // end play()
class player{
private Card[] playerOneCards;
private Card[] playerTwoCards;
private int[] value;
taketurn(deck d, int round)
{
value = new int[round+3];
playerOneCards = new Card[round+2];
playerTwoCards = new Card[round+2];
//(round+2) is the handsize at any given time
for (int x=0; x<round+3; x++)
{
playerOneCards[x] = d.drawFromDeck(); //fills up one hand.
playerTwoCards[x] = d.drawFromDeck(); //fills up second hand.
}
}
}
public class DockOfCards {
private Card theCard;
private int remainingCards = 52;
DockOfCards() {
theCard = new Card();
}
public void shuffle(){
for (int i = 0; i < deck.length; i++) {
int index = (int)(Math.random() deck.length);
int temp = deck[i];
deck[i] = deck[index];
deck[index] = temp;
remainingCards--;
}
}
public void deal(){
for (int i = 0; i < 52; i++) {
String suit = suits[deck[i] / 13];
String rank = ranks[deck[i] % 13];
System.out.println( rank + " of " + suit);
System.out.println("Remaining cards: " + remainingCards);
}
}
}
public class Card {
int[] deck = new int[52];
String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
String[] ranks = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};
Card() {
for (int i = 0; i < deck.length; i++) {
deck[i] = i;
}
}
}
public class human
{
void taketurn()
{
System.out.println("human is handling game");
}
}
public class AI
{
void taketurn()
{
System.out.println("AI hamdling game");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.