I’m working through Cumulative Project 3 (“Game Logic Pt. I”) and when I run the Main.java file I get this error:
Main.java:11: error: method isCorrect in class Question cannot be applied to given types;
if (testQuestion.isCorrect()) {
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length
1 error
I can’t figure out why I’m getting this error as I think my isCorrect method should work. Here is my entire Question.java code:
public class Question {
int imageId;
String questionText;
String answer0;
String answer1;
String answer2;
String answer3;
int correctAnswer;
int playerAnswer;
public Question(int imageIdentifier,
String questionString,
String answerZero,
String answerOne,
String answerTwo,
String answerThree,
int correctAnswerIndex) {
imageId = imageIdentifier;
questionText = questionString;
answer0 = answerZero;
answer1 = answerOne;
answer2 = answerTwo;
answer3 = answerThree;
correctAnswer = correctAnswerIndex;
playerAnswer = -1;
}
// Add isCorrect() here
boolean questionCorrect;
boolean isCorrect(int correctAnswer, int playerAnswer){
if (correctAnswer == playerAnswer) {
questionCorrect = true;
} else {questionCorrect = false;}
return questionCorrect;
}
}
Is there something I’m missing? Thanks in advance for any assistance!