java - missing return type compile error -
i have tostring
method bunch of nested if
statements. think have right i'm getting "missing return statement" error. can see why? thanks.
public string tostring() //to tell user card/s have //c.tostring() { //for printing?// // arraylist<string> forprint = new arraylist<string>(); getsuit(); getvalue(); for(int = 0; < 5; i++) { if(suit == 1) { if(value == 11) { return "jack of clubs"; // forprint.add("jack of clubs"); } else if(value == 12) { return "queen of clubs"; // forprint.add("queen of clubs"); } else if(value == 13) { return "king of clubs"; // forprint.add("king of clubs"); } else if(value == 1) { return "ace of clubs"; // forprint.add("ace of clubs") } else { return value + " of clubs"; // forprint.add(value + " of clubs"); } } else if(suit == 2) { if(value == 11) { return "jack of diamonds"; // forprint.add("jack of diamonds"); } else if(value == 12) { return "queen of diamonds"; // forprint.add("queen of diamonds"); } else if(value == 13) { return "king of diamonds"; // forprint.add("king of diamonds"); } else if(value == 1) { return "ace of diamonds"; // forprint.add("ace of diamonds"); } else{ return value + "of diamonds"; // forprint.add(value + " of diamonds"); } } else if(suit == 3) { if(value == 11) { return "jack of hearts"; // forprint.add("jack of hearts"); } else if(value == 12) { return "queen of hearts"; // forprint.add("queen of hearts"); } else if(value == 13) { return "king of hearts"; // forprint.add("king of hearts"); } else if(value == 1) { return "ace of hearts"; // forprint.add("ace of hearts"); } else { return value + "of hearts"; // forprint.add(value + " of hearts"); } } else if(suit == 4) { if(value == 11) { return "jack of spades"; // forprint.add("jack of spades"); } else if(value == 12) { return "queen of spades"; // forprint.add( } else if(value == 13) { return "king of spades"; } else if(value == 1) { return "ace of spades"; } else { return value + "of spades"; } } else{ return "none"; } //this never happen } }
put
return "none";
in end of method.
Comments
Post a Comment