Question [] questions;
PImage [] bg;
int nr_img=10;
int counter=0;
void setup(){
size(600,600);
String [] text=loadStrings("questions.txt");//load the file
questions=new Question[text.length];
for(int i=0;i<questions.length;i++){
String [] q=(split(text[i],","));
questions[i]=new Question(q[i+1]);
}
}
class Question{
String [] options;
int qnumber;
int score;
Question(String [] options_){
options=options_;
}
void showQuestion(){
for(int i=0;i<10;i++){
text(options[i],300,300);
}
}
Hi everyone!
What I am trying to do here is use the questions from my text file which has 10 lines, so that I can show them on screen. I am using split to get a question per index using comma as a delimiter. I get the error that this constructor does not exist. While this is not close to done, it is what I have so far.
I hope the code is in the right format.
Any type of help would be greatly appreciated!
Thanks in advance!
Hello and thank you for responding!
I am using text.length so that the size of my array of Question objects is set according to the number of lines on my file.
The error does not appear when I use string instead of array of strings in the class attributes and constructor.
Is there a different approach that will not give me this error?