Trying to create a code that will print out the face value and suit of randomly pulled set of 5 cards. For some reason it only prints out the input to the methods but not the results of the methods. Can someone please tell where I am going wrong? Thanks! for the results I am getting Output:
3 of 1
2 of 5
2 of 6
0 of 11
3 of 12
import java.util.*;
public class Card {
static int suits = 0;
static int values = 0;
static String c, d,e,f;
public String getSuit()
{
if (c == "0")
e = ("Hearts");
else
if (c == "1")
e = "Spades";
else
if (c == "2")
e = "Clubs";
else
if (c == "3")
e = "Diamonds";
else
e=c;
return e;
}
public String getValue() {
if (d == "0")
f = ("Ace");
else
if (d =="11")
f = ("Jack");
else
if (d == "12")
f = ("Queen");
else
if (d == "13")
f = ("King");
else
f =d;
return f;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Random gen = new Random();
int [] suits = new int[4];
{
for (int index=0;index<suits.length; index++)
suits[index] = index;
}
int [] values = new int[14];
{
for (int j = 0; j<values.length;j++)
values[j]= j;
}
for (int g = 0; g<5; g++)
{
int a = gen.nextInt(suits.length);
int b = gen.nextInt(values.length);
c = Integer.toString(a);
d = Integer.toString(b);
//System.out.println(c);
//System.out.println(d);
Card draw = new Card ();
draw.getSuit();
draw.getValue();
System.out.println(e + " of "+f);
}
}