Converting ints to Strings Problem
Is it possible to convert an int to a String such as an int with the value of 1 to a String with the value of "Ace"?
Ive tried using the Integer.toString command but it just outputs the integer of 1 converted to the String of "1"
The coding I have done so far in this class is shown below:
Code:
public class Card
{
public final static int DIAMONDS = 1; //Suits
public final static int CLUBS = 2;
public final static int HEARTS = 3;
public final static int SPADES = 4;
public final static int ACE = 1; //Ranks
public final static int TWO = 2;
public final static int THREE = 3;
public final static int FOUR = 4;
public final static int FIVE = 5;
public final static int SIX = 6;
public final static int SEVEN = 7;
public final static int EIGHT = 8;
public final static int NINE = 9;
public final static int TEN = 10;
public final static int JACK = 11;
public final static int QUEEN = 12;
public final static int KING = 13;
public static void main(String[] args)
{
for(int rank = ACE; rank <= KING; rank++)
{
for(int suit = DIAMONDS; suit <= SPADES; suit++)
{
[COLOR="Red"]String A ="Ace";
String B ="Diamonds";
A = Integer.toString(ACE);
B = Integer.toString(DIAMONDS);[/COLOR]
System.out.println(A + " of " + B); //testing
}
}
}
}
Can anyone tell me where I am going wrong?
The program I am trying to create is to have the above class create one object at a time containing a rank and a suit (eg. Ace of Diamonds), which sends the object to another class that makes up a deck of cards. A third class outputs the deck of cards.