Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a JavaFX Application that will respond to button clicks Shuffle, Sort, Show/Hide Deck. You can display the deck either with string representation like 2. 3.

a JavaFX Application that will respond to button clicks Shuffle, Sort, Show/Hide Deck. You can display the deck either with string representation like 2. 3. 2c 3c 4c 2d 3d 4d 2h 3h 4h 2s 3s A Or display the images in that order You may want to create a 5 card poker game and tellif they won a pair, triples or other jackpots. 4. To complete the project: You will need to research and get images for a deck of cards. Plan out the java application user interface You will need to learn about sorting, and show the original just opened deck to customers. . . You will plan to how you are going to shuffle the order of cards .Create the 5 card poker game, display the cards and specify the winnings

Here are my codes

Card Class

import javafx.scene.image.Image; public class Card { private String span; private int rank; private int type; private Image img; public Card() { rank = 0; type = 0; //img = getImage(); //Image backImg = new Image("PNG/blue_back.png"); } public void setRank(int r) { rank = r; } public void setSuit(int s) { type = s; } public int getRank() { return rank; } public String getSuit() { switch (type) { case 1: return "spades"; case 2: return "hearts"; case 3: return "diamonds"; case 4: return "clubs"; default: return "Joker"; } } // gets the individual image for each card by sorting cases by type then rank private Image getImage() { Image i = new Image("PNG/blue_back.png"); switch (type) { case 1: switch (rank) { case 1: i = new Image("PNG/AS.png"); case 2: i = new Image("PNG/2S.png"); case 3: i = new Image("PNG/3S.png"); case 4: i = new Image("PNG/4S.png"); case 5: i = new Image("PNG/5S.png"); case 6: i = new Image("PNG/6S.png"); case 7: i = new Image("PNG/7S.png"); case 8: i = new Image("PNG/8S.png"); case 9: i = new Image("PNG/9S.png"); case 10: i = new Image("PNG/10S.png"); case 11: i = new Image("PNG/JS.png"); case 12: i = new Image("PNG/QS.png"); case 13: i = new Image("PNG/KS.png"); default: i = new Image("PNG/AS.png"); } break; case 2: switch (rank) { case 1: i = new Image("PNG/AH.png"); case 2: i = new Image("PNG/2H.png"); case 3: i = new Image("PNG/3H.png"); case 4: i = new Image("PNG/4H.png"); case 5: i = new Image("PNG/5H.png"); case 6: i = new Image("PNG/6H.png"); case 7: i = new Image("PNG/7H.png"); case 8: i = new Image("PNG/8H.png"); case 9: i = new Image("PNG/9H.png"); case 10: i = new Image("PNG/10H.png"); case 11: i = new Image("PNG/JH.png"); case 12: i = new Image("PNG/QH.png"); case 13: i = new Image("PNG/KH.png"); default: i = new Image("PNG/AS.png"); } break; case 3: switch (rank) { case 1: i = new Image("PNG/AD.png"); case 2: i = new Image("PNG/2D.png"); case 3: i = new Image("PNG/3D.png"); case 4: i = new Image("PNG/4D.png"); case 5: i = new Image("PNG/5D.png"); case 6: i = new Image("PNG/6D.png"); case 7: i = new Image("PNG/7D.png"); case 8: i = new Image("PNG/8D.png"); case 9: i = new Image("PNG/9D.png"); case 10: i = new Image("PNG/10D.png"); case 11: i = new Image("PNG/JD.png"); case 12: i = new Image("PNG/QD.png"); case 13: i = new Image("PNG/KD.png"); default: i = new Image("PNG/AS.png"); } break; case 4: switch (rank) { case 1: i = new Image("PNG/AC.png"); case 2: i = new Image("PNG/2C.png"); case 3: i = new Image("PNG/3C.png"); case 4: i = new Image("PNG/4C.png"); case 5: i = new Image("PNG/5C.png"); case 6: i = new Image("PNG/6C.png"); case 7: i = new Image("PNG/7C.png"); case 8: i = new Image("PNG/8C.png"); case 9: i = new Image("PNG/9C.png"); case 10: i = new Image("PNG/10C.png"); case 11: i = new Image("PNG/JC.png"); case 12: i = new Image("PNG/QC.png"); case 13: i = new Image("PNG/KC.png"); default: i = new Image("PNG/AS.png"); } break; } return i; } }

Deck classimport java.util.Random; public class Deck { private Card deck[]; public Deck() { int count = 0; Card[] deck = new Card[52]; do { Card card = new Card(); deck[count] = card; //if (rank < 13) rank = 1; switch (count) { case 14: card.setRank(2); break; case 27: card.setRank(3); break; case 41: card.setRank(4); default: card.setRank(1); } count++; } while (count <= 51); } public void shuffleDeck() { Random gen = new Random(); for (int i = deck.length - 1; i > 0; i--) { int index = gen.nextInt(i + 1); Card x = deck[index]; deck[index] = deck[i]; deck[i] = x; } } public Card testRank(int i) { return deck[i]; } public Card testSuit(int i) { return deck[i]; } }?

Test /** * Write a description of class Test here. * * @author (your name) * @version (a version number or a date) */ public class Test { public static void main(String[] args) { Deck tdeck = new Deck(); System.out.println("Rank: " + tdeck.testRank(25).getRank()); System.out.println("Suit: " + tdeck.testSuit(25).getSuit()); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

Bring out the limitations of planning.

Answered: 1 week ago

Question

Why should a business be socially responsible?

Answered: 1 week ago

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago