0

Enum Class

public enum Suit {
    CLUB(0, "Clubs"), 
    DIAMOND(1, "Diamonds"), 
    HEART(2, "Hearts"), 
    SPADE(3, "Spades");}

private Suit(int sNum, String sName){
    setsuitNumber(sNum);
    setsuitName(sName);

public String num2suit(String suitName, int suitNumber){
    return String.format("%s",suitName, suitNumber);}
public static String getSuitName() {
    return suitName;}


static void setsuitName(String suitName) {
Suit.suitName = suitName;}

static void setRandomSuit(Suit[] x) {
Suit.suitName = suitName;
Suit.suitNumber = suitNumber;}
//This is where I "think" I should pass the Suit. CLUB.values() to

Game Class - basically where I try to generate a random number between 0 and 3 to generate a suit of a card (I have another method to generate a rank not pictured but same logic).

public static Suit[] randomSuit(){ 

Suit[] x = null;
int randomSuit = (int )(Math.random() * 3 + 1);
    switch (randomSuit){
    case 0:
    x = Suit.CLUB.values(); //not sure what to do here to pass CLUB values
    break;                          to get/set methods                          
    case 1:
    x = Suit.HEART.values();
    break;
...
return x;}}

Card Class to generate a card.

public void setSuit(Suit suit) {
    this.suit = suit;}

public Suit getSuit() {
    return suit;}

public static String getName(){
    return Rank.getRankName() + " of " + Suit.getSuitName();}

Tester

public static void main(String[] args){
Game.randomSuit();
System.out.println(Suit.getSuitName()); //Literally just trying to see if it 
                                        //even passed the values of the
                                        //Suit.CLUB enum to the method
                                        //(it didn't)

Sorry for the noob question, our professor is a temporary "step-in" who's never used Java before, and thus can't answer almost anything, so I must rely on StackOverflow and YouTube to teach myself. I appreciate any feedback.

Yoleaux
  • 49
  • 6
  • 1
    You posted a bunch of code but it's not really clear what the question is. It's great that you have decided to self learn and that SO is one of your resources, but you are going to need to learn to ask better questions if that is the case. What specific part of the code gives you trouble? What is your question? – nhouser9 Nov 15 '16 at 07:48
  • Very messy code, I can't even see what is it trying to do. Explain it some more, form a propper question. Also, if you are starting with java, or programming respectively, a poker game is not a good start – Poody Nov 15 '16 at 07:54
  • Edit your question please, according to: http://stackoverflow.com/help/mcve – eldo Nov 15 '16 at 08:26
  • Your curly braces are all wrong, format it properly if it's copy mistake, if it's not then use some IDE like Eclipse for compile-time checking. – Shadov Nov 15 '16 at 09:01

0 Answers0