You want to devise a way for the app, here JPF1, to message the CQ class that it is time to stop asking questions and give the results. So you can add a method to the CQ class which the JPF1 class can call by using its reference to its instance of CQ, viz, "cq". Then you want to devise a way to do this (make the change from questions to results) in CQ. As a pseudo code suggestion you might try something like this to get started:
class GQ extends JFrame implements ActionListener {
...
public void actionPerformed(ActionEvent e) {
...
} else if (ac.equals("b4")) {
System.exit(0);
}
askQuestions(questions, answers);
}
public void stopAndShowResults() {
timeForMore = false;
}
...
private void askQuestions(String[] questions, String[] answers) {
...
for(int j = 0; j < questions.length; j++) {
if(!timeForMore)
break;
String input = JOptionPane.showInputDialog(null, questions[j]);
if(answers[j].equals(input)) {
count++;
point++;
}
}
...
using the classes/code in reply 2.