Cannot find a class or type name Circle

Hello! I’m recently new to java -processing, and we’re curently working on an animation assignment. I keep getting a class error message, that states "Cannot find a class or type named “Circle”.

If anyone could help me it would be greatly appreciated!

int dragon;
int dragonSkin = #d1afe8;
int horn = 255;
int AltDragonSkin =#99afe6;
int n_of_circles = 25;
Circle[] circles = new Circle[n_of_circles];

void setup() {
  size(500, 500);
  for (int i = 0; i < n_of_circles; i++) {
    circles[i] = new Circle(1, 9);
  }
}

void draw() {  
  dragon();
  background(#a7ecc3);
  
    {
  fill(dragonSkin);{
 beginShape();//body
  vertex(7, 500);
  bezierVertex(85, 425, 65, 370, 110, 360);//back
  bezierVertex(75, 280, 95, 280, 125, 245);//neck
  bezierVertex(195, 250, 145, 250, 137, 285);//other side
   bezierVertex(135, 305, 130, 300, 175, 370);//other side
  bezierVertex(230, 455, 135, 470, 170, 500);//chest
  endShape();
  
  beginShape();//body line
curveVertex(130,408);
curveVertex(130,408);
curveVertex(137,440);
curveVertex(125,460);
curveVertex(122,465);
curveVertex(120,470);
curveVertex(120,470);
endShape();

 beginShape();//wing
  vertex(90, 390);
   bezierVertex(80, 390, 50, 375, 50, 400);
  for (int i = 0; i < n_of_circles; i++) {
    circles[i].display();
    circles[i].move();
  }
}

class Circle {
  float posX = random(0, width); //for movement
  float posY = random(0, height); //cont.
  float speedX = 1000; //direction
  float speedY = 1000; //direction

 
  
  int diameter = 50;
  int radius = diameter/2;


  Circle(float min_speed, float max_speed) {
      
      speedX = random(min_speed, max_speed);
      speedY = random(min_speed, max_speed);
  }

  void display() {
     
      pushStyle();
      fill(#89CFF0);
       ellipse(posX, posY, diameter, diameter);    
      popStyle();
  }
  
  void move(){    
    posX += speedX;
    posY += speedY;
    bounce();

  }

  void bounce() {
      //for left or side edges
      if (posX - 15 < 0 || posX + radius > width) {
        speedX *= - 1; //inverts the sign
  
        if (posX - 15 < 0 ){ posX = radius; }
        if (posX + 15 > width ){ posX = width-radius; }
      }
      //for touching top or bottom edges
      if (posY - radius < 0 || posY + radius > height) {
        speedY *= -1; //inverts the sign

   
        if (posY - radius < 0 ){ posY = radius; }
        if (posY + radius > height ){ posY = height-radius; }
      }

  }
}
 
} 

Your error is in the layout of the curly brackets. I suggest you look at the code in the PDE, press ctrl+t there and then follow each curly bracket starting from the top. Also, class Circle needs to be placed on the global scope. That is the main reason why you get the error.

Kf

1 Like

I just realized I never thanked you. Thank you for helping me! I was able to figure it out.

2 Likes