# Creating a Simple class with a circle

**URL:** <https://discourse.processing.org/t/creating-a-simple-class-with-a-circle/24066>\
**Category:** Coding Questions\
**Created:** [September 23, 2020, 2:57am UTC](https://discourse.processing.org/t/creating-a-simple-class-with-a-circle/24066 "2020-09-23T02:57:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FloorBean](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@FloorBean](https://discourse.processing.org/u/FloorBean)\
**Post date:** [September 23, 2020, 2:57am UTC](https://discourse.processing.org/t/creating-a-simple-class-with-a-circle/24066/1 "2020-09-23T02:57:25Z")

</div>

Hello, I am trying to make a class with just a simple circle. I am planning to eventually have more circles too, but I think that I am running into a syntax/logic error. Any help would be greatly appreciated.

bubble b1;  
void setup(){  
size(300,400);  
b1 = new bubble(10,30,10,10);  
}

void draw(){  
background(255);  
b1.display();  
}

class bubble{  
float x;  
float y;  
float dx;  
float dy;

bubble(float x, float y, float dx, float dy){  
this.x=x;  
this.y=y;  
this.dx=dx;  
this.dy=dy;  
}  
}

void display(){  
fill(0);  
ellipse(random(0,width-30),height-30, 30,30);  
}

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [September 23, 2020, 3:21am UTC](https://discourse.processing.org/t/creating-a-simple-class-with-a-circle/24066/2 "2020-09-23T03:21:34Z")

</div>

Hi remember to use control + shift + c to format code.

Your code is fine, its just the final display function is not inside your class.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [September 23, 2020, 9:41am UTC](https://discourse.processing.org/t/creating-a-simple-class-with-a-circle/24066/3 "2020-09-23T09:41:21Z")

</div>

Use ctrl-t in the processing ide (not the forum) to get auto-indent.

Then you can spot when it’s not in the class.

Also in display () you don’t use x,y and dx,dy

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [September 25, 2020, 12:34pm UTC](https://discourse.processing.org/t/creating-a-simple-class-with-a-circle/24066/4 "2020-09-25T12:34:40Z")

</div>

when you are planning to use 4 or more bubbles look at array or ArrayList please.

It’s a list of bubbles you can have automatically loops over.
