1

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;
         }
Shnoodle
  • 11
  • 1

2 Answers2

1

You're missing a brace after the while statement

Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265
0

I actually just messed up my brackets oops. Hopefully if u are having the same issue looking at your brackets fixes it!

Shnoodle
  • 11
  • 1