unexpected token: Void ?

FMCFMC
edited October 2013 in Using Processing

ANSWERED

Answers

  • edited October 2013 Answer ✓

    Always use CTRL+T inside Processing's IDE in order to auto-format your code. :-t
    This way, you'd get much higher chances to discover that you've forgotten setup()'s closing curling brace there! :(|)

    Also, when posting code here, highlight it and hit CTRL+K! :ar!

  • Thanks a lot. Appreciated!

  • Erased code: >:)

    Person myPerson; 
    Stress myStress; 
    
    // Wrong! width & height are 0 before setup()!!!
    float headX = width/2; 
    float headY = height/3; 
    float stressX = width/2; 
    float stressY = height/3;
    
    void setup() { 
      size(500, 500);
    
      myPerson = new Person(headX, headY); 
      myStress = new Stress(stressX, stressY);
    }
    
    void draw() { 
      if (mousePressed) { 
        if (mouseY <= height/2) { 
          println("Stressed Out"); 
          //Stress.redness();  // Gotta use object's reference instead!!!
          myStress.redness();
        } 
        else { 
          println("Relaxed"); 
          //Person.display();  // Gotta use object's reference instead!!!
          myPerson.display();
        }
      }
    }
    
    class Stress { 
      float stressX = width/2; 
      float stressY = height/3;
    
      Stress(float _x, float _y) { 
        stressX = _x; 
        stressY = _y;
      }
    
      void redness() { 
        fill(255, 0, 0); 
        ellipse(stressX, stressY + 7, 45, 50); //head
    
        //eyes
        fill(255);
        ellipse(stressX - 8, stressY + 2, 14, 14);  //left eye
        fill(0, 0, 255);
        ellipse(stressX - 5, stressY + 3, 2, 2);  //left pupil
        fill(255);
        ellipse(stressX + 8, stressY + 2, 14, 14);  //right eye
        fill(0, 0, 255);
        ellipse(stressX + 5, stressY + 3, 2, 2);  //right pupil
    
        //mouth
        fill(255);
        ellipse(stressX, stressY + 15, 20, 10);
    
        //hair
        stroke(222, 152, 2); 
        line(stressX-1, stressY-18, stressX-3, stressY-25);
        line(stressX-1, stressY-18, stressX+1, stressY-25);
        line(stressX-3, stressY-18, stressX-5, stressY-25);
        line(stressX-5, stressY-18, stressX-7, stressY-25);
        line(stressX-7, stressY-18, stressX-9, stressY-25);
        line(stressX-9, stressY-17, stressX-11, stressY-24);
        line(stressX-11, stressY-14, stressX-13, stressY-21);
        line(stressX-13, stressY-14, stressX-15, stressY-21);
        line(stressX-15, stressY-14, stressX-17, stressY-21);
        line(stressX+1, stressY-18, stressX+3, stressY-25);
        line(stressX+1, stressY-18, stressX-1, stressY-25);
        line(stressX+3, stressY-18, stressX+5, stressY-25);
        line(stressX+5, stressY-18, stressX+7, stressY-25);
        line(stressX+7, stressY-18, stressX+9, stressY-25);
        line(stressX+9, stressY-17, stressX+11, stressY-24);
        line(stressX+11, stressY-14, stressX+13, stressY-21);
        line(stressX+13, stressY-14, stressX+15, stressY-21);
        line(stressX+15, stressY-14, stressX+17, stressY-21);
    
        stroke(0);
        line(stressX, stressY - 18, stressX-2, stressY - 25);
        line(stressX, stressY - 18, stressX, stressY-25);
        line(stressX-2, stressY-18, stressX-4, stressY-25);
        line(stressX-4, stressY-18, stressX-6, stressY-25);
        line(stressX-6, stressY-18, stressX-8, stressY-25);
        line(stressX-8, stressY-17, stressX-10, stressY-24);
        line(stressX-10, stressY-14, stressX-12, stressY-21);
        line(stressX-12, stressY-14, stressX-14, stressY-21);
        line(stressX-14, stressY-14, stressX-16, stressY-21);
        line(stressX, stressY - 18, stressX+2, stressY-25);
        line(stressX+2, stressY-18, stressX+4, stressY-25);
        line(stressX+4, stressY-18, stressX+6, stressY-25);
        line(stressX+6, stressY-18, stressX+8, stressY-25);
        line(stressX+8, stressY-17, stressX+10, stressY-24);
        line(stressX+10, stressY-14, stressX+12, stressY-21);
        line(stressX+12, stressY-14, stressX+14, stressY-21);
        line(stressX+14, stressY-14, stressX+16, stressY-21);
      }
    }
    
    class Person { 
      float headX = width/2; 
      float headY = height/3;
    
      Person(float x, float y) { 
        headX = x; 
        headY = y;
      }
    
      void display() { 
        fill(252, 246, 189); 
        stroke(0); 
        ellipse(headX, headY + 7, 45, 50); //head
    
        //eyes
        fill(255);
        ellipse(headX - 5, headY + 2, 7, 7);  //left eye
        fill(0, 0, 255);
        ellipse(headX - 5, headY + 3, 2, 2);  //left pupil
        fill(255);
        ellipse(headX +5, headY + 2, 7, 7);  //right eye
        fill(0, 0, 255);
        ellipse(headX + 5, headY + 3, 2, 2);  //right pupil
    
        //nose
        stroke(0);
        line(headX, headY+9, headX - 2, headY + 12);
        line(headX - 2, headY +12, headX, headY + 12);
    
        //mouth
        line(headX - 5, headY +20, headX - 3, headY + 18);
        line(headX - 3, headY + 18, headX - 1, headY +20);
        line(headX - 1, headY +20, headX +1, headY+18);
        line(headX + 1, headY+18, headX+3, headY+20);
    
        //hair
        stroke(222, 152, 2); 
        line(headX-1, headY-18, headX-3, headY-10);
        line(headX-1, headY-18, headX+1, headY-10);
        line(headX-3, headY-18, headX-5, headY-10);
        line(headX-5, headY-18, headX-7, headY-10);
        line(headX-7, headY-18, headX-9, headY-10);
        line(headX-9, headY-17, headX-11, headY-9);
        line(headX-11, headY-14, headX-13, headY-8);
        line(headX-13, headY-14, headX-15, headY-8);
        line(headX-15, headY-14, headX-17, headY-8);
        line(headX+1, headY-18, headX+3, headY-10);
        line(headX+1, headY-18, headX-1, headY-10);
        line(headX+3, headY-18, headX+5, headY-10);
        line(headX+5, headY-18, headX+7, headY-10);
        line(headX+7, headY-18, headX+9, headY-10);
        line(headX+9, headY-17, headX+11, headY-9);
        line(headX+11, headY-14, headX+13, headY-8);
        line(headX+13, headY-14, headX+15, headY-8);
        line(headX+15, headY-14, headX+17, headY-8);
    
        stroke(0);
        line(headX, headY - 18, headX-2, headY-10);
        line(headX, headY - 18, headX, headY-10);
        line(headX-2, headY-18, headX-4, headY-10);
        line(headX-4, headY-18, headX-6, headY-10);
        line(headX-6, headY-18, headX-8, headY-10);
        line(headX-8, headY-17, headX-10, headY-8);
        line(headX-10, headY-14, headX-12, headY-9);
        line(headX-12, headY-14, headX-14, headY-8);
        line(headX-14, headY-14, headX-16, headY-8);
        line(headX, headY - 18, headX+2, headY-10);
        line(headX+2, headY-18, headX+4, headY-10);
        line(headX+4, headY-18, headX+6, headY-10);
        line(headX+6, headY-18, headX+8, headY-10);
        line(headX+8, headY-17, headX+10, headY-8);
        line(headX+10, headY-14, headX+12, headY-9);
        line(headX+12, headY-14, headX+14, headY-8);
        line(headX+14, headY-14, headX+16, headY-8);
      }
    

    }

Sign In or Register to comment.