import java.util.Random;
public class Card
{
public String cardGeneration()
{
Random generator = new Random();
int x; // random integer representing suit
int y; // random integer for card value
String mysuit, mynumber; //assigning names, these will be changed
int suits = 4, numbers = 13; //depending what card is picked
x = generator.nextInt(suits); // random integer between 0 & 3 inclusive
if (x == 0)
mysuit = "Clubs";
else if (x == 1)
mysuit = "Diamonds";
else if (x == 2)
mysuit = "Hearts";
else if (x == 3)
mysuit = "Spades";
else
mysuit = "NA";
y = generator.nextInt(numbers) + 1; // add 1 so that y is between 1 & 13 inclusive
if (y == 1)
mynumber = "Ace";
else if (y == 2)
mynumber = "Two";
else if (y == 3)
mynumber = "Three";
else if (y == 4)
mynumber = "Four";
else if (y == 5)
mynumber = "Five";
else if (y == 6)
mynumber = "Six";
else if (y == 7)
mynumber = "Seven";
else if (y == 8)
mynumber = "Eight";
else if (y == 9)
mynumber = "Nine";
else if (y == 10)
mynumber = "Ten";
else if (y == 11)
mynumber = "Jack";
else if (y == 12)
mynumber = "Queen";
else if (y == 13)
mynumber = "King";
else
mynumber = "NA";
String result = mynumber + " of " + mysuit;
return result;
}
}
All this time I haven't been indenting, I've seen examples but I don't know how to do it for this one...