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

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:

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.

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

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 :slight_smile: 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.

1 Like

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

1 Like

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.

1 Like

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

They are also called curly braces.

2 Likes

Hi
class explain

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