私はJavaに関連していて、最初の半重大割り当てを開始しました。私は自分のコードのほとんどが動作していると確信していますが、唯一の問題はクラスを使用していたためです。メインクラスに配列を使用するメソッドを呼び出すことはできません。私が呼びたい他の方法はすべて動作するようです。私は誰かがこれに対する説明や簡単な解決策を持っているのだろうか?配列を使ってメソッドを呼び出す際の問題
お時間をいただきありがとうございます。本当にありがとうございます。
import java.util.Scanner;
public class GeographyQuizMain
{
public static void main(String[] args)
{
takeQuiz();
}
public static void takeQuiz(Question[][] questions)
{
int score = 0;
RandomNumber randomQuestion = new RandomNumber();
//user chooses catergory
int cat = pickCatergory();
//ask 10 questions
for(int i = 0; i < 10;)
{
Scanner answerChoice = new Scanner(System.in);
randomQuestion.dice();
int q = (randomQuestion.dice() - 1);
//checks to see if question as been asked before
if (!questions[cat][q].beenAsked)
{
questions[cat][q].beenAsked = true; //changes question status to beenAsked
System.out.println(questions[cat][q].promt);
String answer = answerChoice.nextLine();
System.out.println("\nYou picked: " + answer + "\nThe correct answer was: " + questions[cat][q].answer + "\n");
if(answer.equals(questions[cat][q].answer))
{
score++;
}
i++;
}
}
System.out.println("That is the end of the quiz!\n"
+ "You got " + score + "/10");
}
あなたの 'Question'クラス内の内容を表示してください –