Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello every one
Iam developing a simple game in processing using java
I am getting an error in my code saying "unexpected token: void" this is in the void setup() part
Can you please:-
1) Help me find the problem and help me solve it.
2) What does unexpected token mean

Here is my code. Additional code as been kept for your batter understanding. But this is not the full code. If you need it please feel free to ask me.

part 1) Is the starting part were some declarations is made
Part 2) Is were i created a class and method. This is where some of the action in the game will take place.
Part 3) The problem according to processing is here. According to it "void setup()" is the problem and it says "unexpected token: void"
1)------------------------------------------------------------------------------------

Java
import TUIO.*;
//import ddf.minim.*;

TuioProcessing tuioClient;

TuioObject tobj;
            
int LocationX=tobj.getScreenX(width);
int LocationY=tobj.getScreenY(height);

HashMap Questions=new HashMap();

HashMap Answers1=new HashMap();

HashMap Answers2=new HashMap();

HashMap Answers3=new HashMap();

HashMap Answers=new HashMap();

HashMap Facts=new HashMap();

HashMap Clues=new HashMap();

HashMap Failed=new HashMap();

HashMap Ultras=new HashMap();

HashMap PopAndNot=new HashMap();

HashMap Music=new HashMap();

HashMap Voices=new HashMap();

HashMap Positions=new HashMap();

HashMap Visible=new HashMap();

PImage BackgroundImage;
PImage Popups;
PImage Popups2;
Popups = loadImage("popupQ.jpg");

//2)----------------------------------------------------------------------------------
public class Questions
{
      int m = 1;
      int c = 1;
      int f = 1;
      String Mu;            
      String clue;
      String failed;
      float r;
      String q;
      String a;
      String aa;
      String aaa;
      String as;
      String f;
      
      void Action()
      {
        Popups2 = loadImage("popupQ.jpg");
        image(Popups2, 0, 0);
        
        while (currentState < 20);
        {
          while (m < 20);
          {
            while (c < 20);
            {
              while (f < 20);
              {
                Mu = Music.get(m);
                Mu.trigger();
            
                clue = Clues.get(c);
                failed = Clues.get(f);
                r = random(1,50);
                q = Questions.get(r);
                a = Answers1.get(r);
                aa = Answers2.get(r);
                aaa = Answers3.get(r);
                as = Answers.get(r);
                f = Facts.get(r);
                text(f, 90,90);
                text(q, 60,60);
                text(a, 30,0);
                text(aa, 40,0);
                text(aaa, 50,60);
            
                if(id==0 && LocationX >=15 && LocationX<=32 && LocationY>=12 && LocationY<14)
                {
                  selectAnswer = a;
                }
                if(id==0 && LocationX >=17 && LocationX<=33 && LocationY>=13 && LocationY<16)
                {
                  selectAnswer = aa;
                }
                if(id==0 && LocationX >=12 && LocationX<=34 && LocationY>=14 && LocationY<17)
                {
                  selectAnswer = aaa;
                }
                if(as == selectAnswer)
                {
                  text.remove();//maybe
                  text(clue, 50,50);
                  text("Next", 30,30);
            
                  if (id==0 && x >=15 && x<=32 && y>=12 && y<14)
                  {
                    //Remove all sh*t
                    currentState++;
                    m++;
                    c++;
                    f++;
                    //super.stop();
                  }
                }
                else
                {
                  //remove popup and questions
                  image(Popups2, 0, 0);
                  Sad.trigger();
                  text(failed, 50,50);
                  text("Next", 30,30);
                  if (id==1 && x >=15 && x<=32 && y>=12 && y<14)
                  {
                    //Clase all
                    Questions();
                  }
                }
              }
            }
          }
        }
      }
}

//3)----------------------------------------------------------------------------------
void setup()
{
 size(6240,4710);
 tuioClient  = new TuioProcessing(this);
 frameRate(30);
 BackgroundImage = loadImage("Map.jpg");
  
  int currentState=0;

Questions.put(1, "What is the next prime number after 7?");
Questions.put(2, "65 – 43"); 
Questions.put(3, "What is the largest type of ‘big cat’ in the world?"); 
Questions.put(4, "True or false? Bats are mammals."); 
Questions.put(5, "What is the fastest land animal in the world?"); 

Answers1.put(1, "11");
Answers1.put(2, "22");
Answers1.put(3, "Cheetah");
Answers1.put(4, "Answers1");
Answers1.put(5, "Horse");

Answers2.put(1, "13");
Answers2.put(2, "21");
Answers2.put(3, "Lion");
Answers2.put(4, "Answers2");
Answers2.put(5, "Cheetah");

Answers3.put(1, "15");
Answers3.put(2, "23");
Answers3.put(3, "Tiger");
Answers3.put(4, "Answers3");
Answers3.put(5, "Rhino");

Answers.put(1, "11");
Answers.put(2, "21");
Answers.put(3, "Tiger");
Answers.put(4, "Answers2");
Answers.put(5, "Rhino");

Facts.put(1, "Facts1");
Facts.put(2, "Facts2");
Facts.put(3, "Facts3");
Facts.put(4, "Facts4");
Facts.put(5, "Facts5");

Clues.put(1, "Clue 1");
Clues.put(2, "Clue 2");
Clues.put(3, "Clue 3");
Clues.put(4, "Clue 4");
Clues.put(5, "Clue 5");

Failed.put(1, "failed 1");
Failed.put(2, "failed 2");
Failed.put(3, "failed 3");
Failed.put(4, "failed 4");
Failed.put(5, "failed 5");

Music.put(1, minim.loadSample("Black Water.mp3"));
Music.put(2, minim.loadSample("byrd.mp3"));
Music.put(3, minim.loadSample("Colossus.mp3"));
Music.put(4, minim.loadSample("Crystal Glaciers.mp3"));
Music.put(5, minim.loadSample("Dead Heroes.mp3"));
Music.put(6, minim.loadSample("Glimmer.mp3"));
Music.put(7, minim.loadSample("Monkey.mp3"));
Music.put(8, minim.loadSample("Sunny Villa.mp3"));
Music.put(9, minim.loadSample("swamp.mp3"));

tuioClient  = new TuioProcessing(this);

loop(); 
}
Posted
Updated 5-Dec-12 0:16am
v3
Comments
TorstenH. 5-Dec-12 6:49am    
is today the "I don't use a IDE"-Day?

Use Eclipse or Netbeans. They are free. There is no reason not to use them.
Both would have told you right away what the problem is.

1 solution

Your problem is that your void setup() method is outside the Questions class.
Move it inside and it should be OK.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900