Error message (cannot find a class or type named 'Person')

edited November 2013 in Using Processing

I keep getting this error message "cannot find a class or type named 'Person'", it was working perfectly fine until I tried adding another class.

here's my general code:

Person myPerson;
Stress myStress;
table myTable;
chair myChair;
papers myPapers;
float r, g, b;

void setup()
{
  size(500, 500);
  background(255, 206, 41);  
  myPerson = new Person(width/2, height/3);
  myStress = new Stress(width/2, height/3);
  myTable = new table(width/4, (3*height)/5);
  myChair = new chair((2*width)/5, height/2);
  myPapers = new papers(width/4,(3*height)/5);
  myChair.display();
  myPerson.display();
  myTable.display();
}


void draw()
{
  if (mousePressed)
  {
    if (mouseY <= height/2)
    {
      r = random(0, 255);
      g = random(0, 255);
      b = random(0, 255);
      background(r, g, b);
      println("Stressed Out");
      myChair.display();
      myStress.redness();
      myTable.display();
      myPapers.flying();
    }
    else
    {
      background(255, 206, 41);
      println("Relaxed");
      myChair.display();
      myPerson.display();
      myTable.display();
    }
  }
}

here's the code for my Person class:

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);
    rect(headX - 7.5, headY, 15, 60);  //neck
    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);

    //arms
    fill(252, 246, 189);  //skin colour
    quad(headX - 70, 245, headX - 55, 245, headX - 40, headY + 120, headX - 50, headY + 120);  //left forearm
    quad(headX + 70, 245, headX+55, 245, headX + 40, headY + 120, headX+50, headY+120);  //right forearm
    fill(93, 94, 98);  //shirt colour

    //body
    stroke(0);
    rect(headX - 40, headY + 40, 80, 100);  //torso
    quad(headX - 75, 250, 210, headY + 41, 210, headY + 70, headX - 50, 245);  //left bicep
    quad(headX+75, 250, 290, headY+41, 290, headY+70, headX+50, 245);  //right bicep

    //hands
    stroke(0);
    fill(252,246,189);   //skin colour
    ellipse(headX - 43, headY + 127, 15, 20);    //left hand
    ellipse(headX + 45, headY + 127, 15, 20);    //right hand

    //legs
    noStroke();
    fill(60, 80, 160);
    rect(218, 330, 25, 80);    //left leg
    rect(258, 330, 25, 80);    //right leg
    quad(210, 310, 290, 310, 283, 330, 218, 330);  //upper legs
    fill(255, 206, 41);
    triangle(243, 330, 250.5, 325, 258, 330);  //groin

    //feet
    fill(0);
    ellipse(230.5, 410, 26, 15);
    ellipse(270.5, 410, 26, 15);
    stroke(255);
    arc(230, 407, 10, 2, -PI, 0);
    arc(230, 410, 10, 2, -PI, 0);
    arc(270, 407, 10, 2, -PI, 0);
    arc(270, 410, 10, 2, -PI, 0);
  }
}
Tagged:

Answers

  • I really don't know what I'm doing wrong, it was working so perfectly, and then all of a sudden the error message came up. I've gone through the whole code and did ctrl+T but nothing has changed. I'd really appreciate if you could have another look. Thanks!

  • After commenting out the missing classes, it's simply worked: [-(

    Person myPerson;
    Stress myStress;
    //table myTable;
    //chair myChair;
    //papers myPapers;
    float r, g, b;
    
    void setup() {
      size(500, 500);
      background(255, 206, 41);  
      myPerson = new Person(width/2, height/3);
      myStress = new Stress(width/2, height/3);
      //myTable = new table(width/4, (3*height)/5);
      //myChair = new chair((2*width)/5, height/2);
      //myPapers = new papers(width/4, (3*height)/5);
      //myChair.display();
      myPerson.display();
      //myTable.display();
    }
    
    
    void draw() {
      if (mousePressed) {
        if (mouseY <= height/2) {
          r = random(0, 255);
          g = random(0, 255);
          b = random(0, 255);
          background(r, g, b);
          println("Stressed Out");
          //myChair.display();
          myStress.redness();
          //myTable.display();
          //myPapers.flying();
        }
        else {
          background(255, 206, 41);
          println("Relaxed");
          //myChair.display();
          myPerson.display();
          //myTable.display();
        }
      }
    }
    
    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);
        rect(headX - 7.5, headY, 15, 60);  //neck
        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);
    
        //arms
        fill(252, 246, 189);  //skin colour
        quad(headX - 70, 245, headX - 55, 245, headX - 40, headY + 120, headX - 50, headY + 120);  //left forearm
        quad(headX + 70, 245, headX+55, 245, headX + 40, headY + 120, headX+50, headY+120);  //right forearm
        fill(93, 94, 98);  //shirt colour
    
        //body
        stroke(0);
        rect(headX - 40, headY + 40, 80, 100);  //torso
        quad(headX - 75, 250, 210, headY + 41, 210, headY + 70, headX - 50, 245);  //left bicep
        quad(headX+75, 250, 290, headY+41, 290, headY+70, headX+50, 245);  //right bicep
    
        //hands
        stroke(0);
        fill(252, 246, 189);   //skin colour
        ellipse(headX - 43, headY + 127, 15, 20);    //left hand
        ellipse(headX + 45, headY + 127, 15, 20);    //right hand
    
        //legs
        noStroke();
        fill(60, 80, 160);
        rect(218, 330, 25, 80);    //left leg
        rect(258, 330, 25, 80);    //right leg
        quad(210, 310, 290, 310, 283, 330, 218, 330);  //upper legs
        fill(255, 206, 41);
        triangle(243, 330, 250.5, 325, 258, 330);  //groin
    
        //feet
        fill(0);
        ellipse(230.5, 410, 26, 15);
        ellipse(270.5, 410, 26, 15);
        stroke(255);
        arc(230, 407, 10, 2, -PI, 0);
        arc(230, 410, 10, 2, -PI, 0);
        arc(270, 407, 10, 2, -PI, 0);
        arc(270, 410, 10, 2, -PI, 0);
      }
    }
    
    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);
      }
    } 
    
  • See if the article Common issues with sketch names can help...

  • edited October 2013 Answer ✓

    sounds like your sketch name is "person" as well... there may be a name collision.

    EDIT: or maybe not.. :(

Sign In or Register to comment.