I have this method that generates random questions, I want to be able to generate each question once and no more than once. How could I do that?
This is the code so far:
package boss;
import java.util.Random;
import javax.swing.JFrame;
public class Boss {
public static void main(String[] args) {
LoginWindow window = new LoginWindow();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
}
public String getQuestions() {
String [] question = new String[30];
question[0] = "hello";
question[1] ="yo";
question[2] ="b";
question[3] ="ha";
//Generating random questions
Random r = new Random();
int i=r.nextInt(4);
String quest=question[i];
return quest;
}
}