0

したがって、基本的に私のコンピュータ サイエンス クラスでは、カード表記 (「4S」など) のユーザー入力を受け取り、カードの説明 (「スペードの 4」) を返す getDescription メソッドを持つ Card クラスを作成する必要があります。問題は、ifステートメントに関して「到達不能ステートメント」エラーが発生し続けることです。私はおそらくすべて間違っていましたが、ここに私がしたことがあります:

import java.util.Scanner;

public class Card 
{ 

private String face; 
private String suit; 

public Card() 
{	
Scanner card = new Scanner(System.in); 
System.out.print("Enter the card notation: "); 
String input = card.next(); 

face = input.substring(0,1); 
suit = input.substring(1); 

} 


public String getDescription() 
{ 

return "Your card was the "; 

if (face.equals("A")) return "ace"; 

return getDescription(); 

} 

}

4

1 に答える 1