public class Card
{
private String rank;
private String suit;
public Card(String input)
{
rank = input.substring(0, 1);
suit = input.charAt(suit.length() - 1);
}
//Return the rank regardless of case input, or output "unknown" if other.
public String getDescription()
{
{
if (rank.equalsIgnoreCase("A"))
rank = "Ace of ";
else if (rank.equalsIgnoreCase("J"))
rank = "Jack of ";
else if (rank.equalsIgnoreCase("Q"))
rank = "Queen of ";
else if (rank.equalsIgnoreCase("K"))
rank = "King of ";
else if (rank.equalsIgnoreCase("2"))
rank = "Two of ";
else if (rank.equalsIgnoreCase("3"))
rank = "Three of ";
else if (rank.equalsIgnoreCase("4"))
rank = "Four of ";
else if (rank.equalsIgnoreCase("5"))
rank = "Five of ";
else if (rank.equalsIgnoreCase("6"))
rank = "Six of ";
else if (rank.equalsIgnoreCase("7"))
rank = "Seven of ";
else if (rank.equalsIgnoreCase("8"))
rank = "Eight of ";
else if (rank.equalsIgnoreCase("9"))
rank = "Nine of ";
else if (rank.equalsIgnoreCase("10"))
rank = "Ten of ";
else
return "Unknown";
}
{
if (rank.equals("Unknown"))
return "Unknown";
else if (suit.equalsIgnoreCase("H"))
rank = rank + "Hearts";
else if (suit.equalsIgnoreCase("D"))
rank = rank + "Diamonds";
else if (suit.equalsIgnoreCase("C"))
rank = rank + "Clubs";
else if (suit.equalsIgnoreCase("S"))
rank = rank + "Spades";
else
return rank;
}
return rank;
}
}
errors
Enter the card notation: 10d Exception in thread "main" java.lang.Error: Unresolved compilation problem: Type mismatch: cannot convert from char to String at Card.<init>(Card.java:13) at CardPrinter.main(CardPrinter.java:15)
This post has been edited by spark69: 14 February 2010 - 01:15 PM

New Topic/Question
Reply




MultiQuote








|