I moved 3 files I was working on to a new package and now have a new error. I am still in the process of getting it working. The error is "Question cannot be resolved to a type" . I am only learning Java and am very new to it. Do I need to add in the other files as well? EDIT : This is question I added to the package but I have an error on this one now "The static field Question.nQuestion should be accessed in a static way" and I don't know why? I used two Asterisk to highlight the section with the error
package com.quiz6;
import javax.swing.JOptionPane;
public abstract class Question {
static int nCorrectAnswer = 0;
static int nQuestion = 0;
String question;
String correctAnswer;
//abstract method ask
public abstract String ask();
//the same method
public void check() {
String answer = ask();
**this.nQuestion++;**
if (answer.equalsIgnoreCase(this.correctAnswer)) {
JOptionPane.showMessageDialog(null, "Correct!");
**this.nCorrectAnswer++;**
} else {
JOptionPane.showMessageDialog(null, "Incorrect");
}
}
public static void showResults() {
JOptionPane.showMessageDialog(null, nCorrectAnswer + " correct out of questions " + nQuestion);
}
}
package com.quiz6;
import com.quiz6.MultipleChoiceQuestion6;
import com.quiz6.TrueFalseQuestion;
public class quiz6 {
public static void main(String[] args) {
**
Question question;
question = new MultipleChoiceQuestion6("What is the capitol of Singapore?", **
"Singapore",
"Dublin",
"Tokyo",
"Shanghai",
"Bangkok.",
"A");
question.check();
question = new MultipleChoiceQuestion6("What is the capitol of America?",
"New York",
"San Francisco",
"Alaska",
"Washington DC",
"Minnesota",
"d");
question.check();
question = new MultipleChoiceQuestion6("What is the capitol of Europe?",
"Ireland",
"Germany",
"Czech Republic",
"France",
"Trick Question",
"e");
question.check();
question = new MultipleChoiceQuestion6("Who accidentally overwrote their Quiz file?",
"Yourself",
"Johann",
"Norberto",
"Trump",
"Me!",
"e");
question.check();
//true or false questions here
question = new TrueFalseQuestion("Sharks are mammals", "FALSE");
question.check();
question = new TrueFalseQuestion("Spiders have six legs.", "FALSE");
question.check();
question = new TrueFalseQuestion("My brain is sore from Java.", "TRUE");
question.check();
//we show the results of the quiz
question.showResults();
}
}