저는 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' 클래스 내에있는 것을 보여주세요. –