# I don't know what I am doing wrong! (class and brackets)

**URL:** <https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [October 15, 2023, 11:26pm UTC](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978 "2023-10-15T23:26:47Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 16, 2023, 12:52am UTC](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978/21 "2023-10-16T00:52:02Z")

</div>

You’re almost there; now you’re ready to fix the bracket pairs. In your Meich class move that closing bracket after the class variables all the way to the end, plus you’ll need one more closing bracket at the end. Class structure looks like this:

```auto
class Meich {
  // class variables
  ...
    //constructor
    Meich() {
     ...
    }
  void display() {
    for () {
      ...
    }
  }
}

```

After that you will need to add all the class variables that was in your original post. You have left a few of them out of the second code post. After all of that I think it will run.

---

<div class="post-metadata">

**Author:** ![Amamallama](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@Amamallama](https://discourse.processing.org/u/Amamallama)\
**Post date:** [October 16, 2023, 12:58am UTC](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978/22 "2023-10-16T00:58:17Z")

</div>

Man, I am still struggling. So this is what I have:

```auto
Meich meich; 
int eyeSize, eyeSize2;

void setup() {
 
}

void draw() {
 
}

class Meich {
  // Meich's variables
  float meichX, meichY, meichW, meichH, eyeSize;

  // Meich constructor
 Meich(float tempX, float tempY, float tempW, float tempH, float tempEyeSize) {
    meichX = tempX;
    meichY = tempY;
    meichW = tempW;
    meichH = tempH;
    eyeSize = tempEyeSize;
 }

  // Move Meich
  void jiggle(float speed) {
    // Change the location of Meich randomly
    meichX = meichX + random(-1, 1)*speed;
    meichY = meichY + random(-1, 1)*speed;
    // Constrain Meich to window
    meichX = constrain(meichX, 0, width);
    meichY = constrain(meichY, 0, height);

  }
  // Display Meich
  void display() {
    // Set ellipses and rects to CENTER mode
    ellipseMode(CENTER);
    rectMode(CENTER);
  }
    // Loop Arms
    for (float i = meichY + 5; i < meichY + meichH; i += 10) {
      stroke(0);
      line(meichX-meichW/3, i, meichX+meichW/3, i);
      // Draw body
      //head
      //eyes
      //nose
      // mouth
      //legs
     
    }
   }

```

With these changes, it is now the error "incomplete statement or extra code near extraneous input “for” expecting

it won’t let me make new replys because I am new, but THANK YOU!!! it worked!  
That worked 🙂 Thank you so much. I know I will be back on with more questions, but you helped me understand this far more than I have learned thus far. I now just need to put my class in the other tab and I will be good. Seriously, I am so so grateful that you took the time to teach me.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 16, 2023, 1:01am UTC](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978/23 "2023-10-16T01:01:49Z")

</div>

You messed up display(){…}. Move that closing bracket after _rectMode(CENTER);_ all the way to the end;

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 16, 2023, 1:11am UTC](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978/24 "2023-10-16T01:11:39Z")

</div>

A lot of us here are either active or past teachers so we understand. The main thing is that you kept trying and that’s important for success. Good luck with your course.

---

<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:** [October 16, 2023, 8:19am UTC](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978/25 "2023-10-16T08:19:04Z")

</div>

> [@Amamallama](#):
>
> `class Meich {`

This bracket must close after all the meich functions (presumably at the end of the Sketch)

A class holds the variables, the constructor and the functions of the class

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 16, 2023, 3:23pm UTC](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978/26 "2023-10-16T15:23:33Z")

</div>

They are also called curly _braces_.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [October 16, 2023, 5:29pm UTC](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978/27 "2023-10-16T17:29:15Z")

</div>

Hi  
class explain

[![](https://img.youtube.com/vi/lmgcMPRa1qw/hqdefault.jpg "8.2: Defining a Class Part I - Processing Tutorial") ](https://www.youtube.com/watch?v=lmgcMPRa1qw&t=5s)

[![](https://img.youtube.com/vi/XwfOVFelLoo/hqdefault.jpg "8.3: Defining a Class Part II - Processing Tutorial") ](https://www.youtube.com/watch?v=XwfOVFelLoo)

---

<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:** [October 17, 2023, 12:29pm UTC](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978/28 "2023-10-17T12:29:47Z")

</div>

> [@Amamallama](#):
>
> ```auto
> // Display Meich
> void display() {
> // Set ellipses and rects to CENTER mode
> ellipseMode(CENTER);
> rectMode(CENTER);
> }
> 
> ```

here the bracket } is closing too soon.

It must close after the for loop’s curly bracket } . The whole section is the function (inside the class).

- you can use ctrl-t to get auto-indent. When the indent is wrong, something is wrong (with the } mostly)
- You can place cursor after a { or a } and the corrsponding bracket lights up. Thus you can check if the pairs match and are as you expect them to be.
- just slowly proof read the code

Chrisir

[Previous page](https://discourse.processing.org/t/i-dont-know-what-i-am-doing-wrong-class-and-brackets/42978.md?page=1)
