We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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);
}
}
Answers
That 1 is so much like this post below... ;))
http://forum.processing.org/two/discussion/473/unexpected-token-void-
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: [-(
See if the article Common issues with sketch names can help...
sounds like your sketch name is "person" as well... there may be a name collision.
EDIT: or maybe not.. :(