Question
So in my CS class we have to model playing cards with the classes hand, deck, and card. I got the card class done and
So in my CS class we have to model playing cards with the classes hand, deck, and card. I got the card class done and the majority of the deck and hand class, however I'm getting a little lost on how to finish them up. The link to what my professor wants it to be like is https://cs.uwlax.edu/~jmaraist/120-spring-2017/2017/04/11/cs120-project-4/ . My code so far is:
public class Card { public static final byte CLUB=0; public static final byte DIAMOND=1; public static final byte HEART=2; public static final byte SPADE=3; public static final int Jack = 11; public static final int Queen = 12; public static final int King = 13; public static final int Ace = 14; private final byte suit; private final byte rank; public Card(final byte suit, final byte rank) { this.rank = rank; this.suit = suit; }
public byte getSuit() { return suit; }
public byte getRank() { return rank; } public String suitAsString() { //returns the name for each suit switch ( suit ) { case SPADE: return "Spades"; case HEART: return "Hearts"; case DIAMOND: return "Diamonds"; case CLUB: return "Clubs"; default: return ""; } } public String rankAsString() { //returns the name for each rank switch (rank){ case 1: return ""; case 2: return "Two"; case 3: return "Three"; case 4: return "Four"; case 5: return "Five"; case 6: return "Six"; case 7: return "Seven"; case 8: return "Eight"; case 9: return "Nine"; case 10: return "Ten"; case 11: return "Jack"; case 12: return "Queen"; case 13: return "King"; case 14: return "Ace"; default: return ""; } } public String toString(){ //Method that returns the cards suit and rank in English return rankAsString() + " of " + suitAsString(); } }
import java.util.Random; import java.util.ArrayList;
public class Deck { private static ArrayList import java.util.ArrayList; public class Hand { private static ArrayList } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started