Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

java classes, and return values

Name: Anonymous 2005-11-13 19:35

i have to create two classes. ones a game and the other is a card class that the game calls from. here is my card class

import java.util.Random;
public class card {
   
    private static Random generator = new Random();
    private int value;
    private int suit;
   
    public card() {
        Dealcard();
    }
   
    public void Dealcard(){
       
        value = generator.nextInt(13)+1;
        suit = generator.nextInt(4)+1;
    }
   
    public int Getvalue() {
       
        return value;
    }
   
    public int Getsuit() {
       
        return suit;
    }
   
    public String toString(){
       
        String facevalue;
        if (value >1 && value < 11)
            facevalue = "";
        else if (value == 1)
            facevalue = "ace";
        else if (value == 11)
            facevalue = "jack";
        else if (value == 12)
            facevalue = "queen";
        else
            facevalue = "king";
       
        String facesuit;
       
        if (suit == 1)
            facesuit = "hearts";
        else if (suit == 2)
            facesuit = "spades";
        else if (suit == 3)
            facesuit = "diamonds";
        else
            facesuit = "clubs";
       

    }
}

the whole point in creating the tostring at the bottom is so i can combine the value and suit and have it be returned. how do i have it be returned?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List