-2
私は上記の問題について継続的なエラーが発生しています。助けてください..... 私はこのコードを次の金曜日までに私のプロジェクトの一部として提出しなければなりません。私はインターネット上で他のプログラムを見たことがありますが、それらはすべてバッファリーダーを使用しているので理解できません。bluejの '不正な式の開始'エラーが発生しました
import java.util.*;
//HANGMAN
//ANSH DAWDA XA
class hangman
{
Scanner S=new Scanner(System.in);
String A,W,word,clue;
void h1()
{
System.out.println("_____________");
System.out.println(" | |");
System.out.println(" |");
System.out.println(" |");
System.out.println(" |");
System.out.println(" |");
System.out.println(" |");
System.out.println(" |");
System.out.println("---");
}
void h2()
{
System.out.println("_____________");
System.out.println(" | |");
System.out.println(" | ()");
System.out.println(" |");
System.out.println(" |");
System.out.println(" |");
System.out.println(" |");
System.out.println(" |");
System.out.println("---");
}
void h3()
{
System.out.println("_____________");
System.out.println(" | |");
System.out.println(" | ()");
System.out.println(" | |");
System.out.println(" | |");
System.out.println(" | |");
System.out.println(" |");
System.out.println(" |");
System.out.println("---");
}
void h4()
{
System.out.println("_____________");
System.out.println(" | |");
System.out.println(" | ()");
System.out.println(" | |");
System.out.println(" | |");
System.out.println(" | |");
System.out.println(" | /");
System.out.println(" | |");
System.out.println("---");
}
void h5()
{
System.out.println("_____________");
System.out.println(" | |");
System.out.println(" | ()");
System.out.println(" | |");
System.out.println(" | |");
System.out.println(" | |");
System.out.println(" | /\\");
System.out.println(" | | |");
System.out.println("---");
}
void h6()
{
System.out.println("_____________");
System.out.println(" | |");
System.out.println(" | ()");
System.out.println(" | |");
System.out.println(" | /|");
System.out.println(" | /|");
System.out.println(" | /\\");
System.out.println(" | | |");
System.out.println("---");
}
void h7()
{
System.out.println("_____________");
System.out.println(" | |");
System.out.println(" | ()");
System.out.println(" | |");
System.out.println(" | /|\\");
System.out.println(" | /| \\");
System.out.println(" | /\\");
System.out.println(" | | |");
System.out.println("---");
}
int option;
void sports()
{
option=(int)(Math.random()*10);
switch(option)
{ case 0:
{
clue = "He is an Argentine footballer who plays for La Liga club FC Barcelona and is the captain of the Argentina national team, playing mainly as a forward.";
word = "LIONEL MESSI";
}
break;
case 1:
{
clue = "First person to score 200 in ODIs";
word = "SACHIN TENDULKAR";
break;
}
case 2:
{
clue = "It is a South Asian team sport.";
word = "KABADDI";
}
break;
case 3:
{
clue = "It is a twoplayer board game";
word = "CHESS";
}
break;
case 4:
{
clue = "It is a team sport in which two teams of six players are separated by a net.";
word = "VOLLEYBALL";
}
break;
case 5:
{
clue = "Known as 'The wall'";
word = "RAHUL DRAVID";
}
break;
case 6:
{
clue = "World Table Tennis Champion";
word = "ZHANG JIKE";
}
break;
case 7:
{
clue = "A famous sport";
word = "FOOTBALL";
}
break;
case 8:
{
clue = "Played on a hard board divided by a net";
word = "TABLE TENNIS";
}
break;
case 9:
{
clue = "Grandmaster of chess";
word = "VISHWANATAN ANAND";
}
break;
}
return String {word,clue};
}
}
@Simzeなぜですか?それは全く問題ありません。問題は、最後のメソッドの最後のreturn文です。 – f1sh
@Anshあなたのメソッド '' sports''には返されるvoid型があります。つまり、何も返すことができません。それはあなたがここで試すものです: '' return String {単語、手がかり}; ''。また、そのステートメントは有効な式ではありません。 – f1sh
申し訳ありません私の悪い!コメントを削除しました –