Code:
import java.util.Scanner;
public class Card
{
private int num; // 2...10, 11=J, 12=Q, 13=K, 14=A
private int suit; // 0=club, 1=diamond, 2=heart, 3=spade
//**********************************************************
public Card(int num, int suit)
{
this.num = num;
this.suit = suit;
} // end constructor
//**********************************************************
public int getNum()
{
if (num == 2)
return "2";
if (num == 3)
return "3";
if (num == 4)
return "4";
if (num == 5)
return "5";
if (num == 6)
return "6";
if (num == 7)
return "7";
if (num == 8)
return "8";
if (num == 9)
return "9";
if (num == 10)
return "10";
if (num == 11)
return "Jack";
if (num == 12)
return "Queen";
if (num == 13)
return "King";
if (num == 14)
return "Ace";
} // end constructor
//**********************************************************
public int getSuit()
{
if (suit == 0)
return "Clubs";
if (suit == 1)
return "Diamonds";
if (suit == 2)
return "Hearts";
if (suit == 3)
return "Spades";
} // end constructor
//**********************************************************
public void display()
{
System.out.print(num, "of", suit);
} // end display
} // end Card class
I don't want to convert a string to an int. I just want to return a string from the specified int. Any help??
Comment