The question says: Design and implement a class called Card that represents a standard playing card. Each card has a suit and a face value. Create a program that deals 20 random cards.
this is the card class i made but i dont know if it right...i also don't know how to creatre a program that deals random cards.
public class Card
{
public final static int spades = 0,hearts = 1, diamonds = 2, clubs = 3;
public final static int ace = 1, jack= 11, queen = 12, king= 13;
private final int suit;
private final int value;
public Card(int theValue, int theSuit)
{
value = theValue;
suit = theSuit;
}
public int getSuit()
{
if (suit==0)
return spades;
else if (suit==1)
return hearts;
else if (suit==2)
return diamonds;
else if (suit==3)
return clubs;
return suit;
}
public int getValue()
{
if (value==1)
return ace;
else if (value==11)
return jack;
else if (value==12)
return queen;
else if (value==13)
return king;
return value;
}
public String toString()
{
return getSuit() + " " + getValue();
}
}
this is the card class i made but i dont know if it right...i also don't know how to creatre a program that deals random cards.
public class Card
{
public final static int spades = 0,hearts = 1, diamonds = 2, clubs = 3;
public final static int ace = 1, jack= 11, queen = 12, king= 13;
private final int suit;
private final int value;
public Card(int theValue, int theSuit)
{
value = theValue;
suit = theSuit;
}
public int getSuit()
{
if (suit==0)
return spades;
else if (suit==1)
return hearts;
else if (suit==2)
return diamonds;
else if (suit==3)
return clubs;
return suit;
}
public int getValue()
{
if (value==1)
return ace;
else if (value==11)
return jack;
else if (value==12)
return queen;
else if (value==13)
return king;
return value;
}
public String toString()
{
return getSuit() + " " + getValue();
}
}
Comment