I don't know why I'm getting this return statement :sad: Please help. Error is in green
public class Card {
private int rank;
private int suit;
public Card()
{
suit = (int)Math.floor(Math.random() * (4-1) + 0.5) +4;
rank = (int)Math.floor(Math.random() * (14-2) + 0.5) +14;
}
public Card(int r, int s)
{
if (r>=2 && r<=14)
rank = r;
else rank = 14;
if (s>=1 && s<=4)
suit = s;
else suit = 4;
}
public int getSuit() //returns suit
{
return suit;
}
public int getRank() //return rank
{
return rank;
}
public boolean isHigher(Card c)
{
if (c.getRank() >rank){ //if Card is higher in rank return true
return true;
}
else
if (c.getRank() < rank){ //if Card is lower in rank return false
return false;
}
else
if (c.getRank() ==rank){ //if rank is equal then evaluate suit
if (c.getSuit() >suit){
return true;
}
else
if (c.getSuit() <suit){
return false;
}
}
I get error here }
public String toString()
{
String strRank = "";
String strSuit = "";
if (rank ==14){
strRank = "A";
}
else
if (rank ==13){
strRank = "K";
}
else
if (rank ==12){
strRank = "Q";
}
else
if (rank ==11){
strRank = "J";
}
else
if (rank ==10){
strRank = "10";
}
else
if (rank ==9){
strRank = "9";
}
else
if (rank ==8){
strRank = "8";
}
else
if (rank ==7){
strRank = "7";
}
else
if (rank ==6){
strRank = "6";
}
else
if (rank ==5){
strRank = "5";
}
else
if (rank ==4){
strRank = "4";
}
else
if (rank ==3){
strRank = "3";
}
else
if (rank ==2){
strRank = "2";
}
else
if (rank ==1){
strRank = "1";
}
if (suit==4){
strSuit= "Spades";
}
else
if (suit==3){
strSuit= "Hearts";
}
else
if (suit==2){
strSuit= "Diamonds";
}
else
if (suit==1){
strSuit= "Club";
}
else
return strRank + "of" + strSuit;
and i get the same missing return statement error here