-5

I am using the below code to simulate "Purple Rain" (from The Coding Train on YouTube).

Class Drop(){
  float x = width/2;
  float y = 0;
  float yspeed = 1;

  void fall(){
    y = y + yspeed;
  }
  void show(){
    stroke(138, 43, 226);  //purple rain
    line(x, y, x, y+10);
  }

}

However, I am getting the error unexpected token: void on line 6:

void fall(){     

I can't see any syntax errors - could someone suggest why I am getting this error?

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
anushka
  • 345
  • 4
  • 14

1 Answers1

0

You do have a syntax error. The Class keyword should be class with a lower-case c. You should also not have parenthesis after the class name.

Also, see my answer here. The Processing editor doesn't like when you only have a class definition without Processing functions like setup() and draw().

Side note: you might want to try approaching problems like this with a "what syntax error am I not seeing?" mentality instead of saying "I have no syntax errors" - the compiler doesn't lie, so saying you have no syntax mistakes comes off as a little bit presumptuous.

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107