I am trying to write a choose your own adventure code outline for my class but it says that my variable pg1 has not been initialized but it clearly has and I do not see an outcome where it wouldn't be? Can someone take a look for me and help trouble shoot it?
public static boolean decOne() //the first desicion to make
{
boolean nxt = false;
boolean bonus = false;
int pg1;
Object[] options = {"opt1","opt2","opt3","opt4"};
while(nxt == false)
pg1 = JOptionPane.showOptionDialog(null,"story text goes here","title goes here",1,1,null,options,options[0]);
if(pg1==0)
{
bonus = true;
nxt = false;
}
else if(pg1==1)
{
nxt = false;
}
else if(pg1==2)
{
nxt = true;
}
else if(pg1==3)
{
nxt = false;
}
return bonus;
}