Object-oriented theory doubt. sin() function, oscillation

Hi all,
My understanding of OOP is that in order to create a Class, you need to define 1) variables, 2) constructor and 3) methods. In the example below though, variables x and theta are 1) defined, their values assigned in 2) the constructor, however the x formula to determine its value must be placed as a method. If I put it in the constructor the oscillator won’t move, but if I move it inside void.display() it will.
Why is that??

class Oscillator {
  float theta; //oscillation angle
  float x;
  Oscillator() {
    theta = 0;
  void move() {
    //Increment theta with each cycle to create movement
    theta += 0.05;

  void display() {
    //draw the ellipse at the value produced by sine
    x = map(sin(theta),-1,1,0,width); // this can't go in the constructor?!?

A class constructor is called once only, when it’s instantiated.
A method can be called indefinitely.

1 Like

Got it, thank you! Cheers