help making a class

Can anyone direct me to a tutorial for like turning a function into a class? I want to add functionality to what I have but I can't seem to get it to work
right now the way they works is it loops thru the function for the given button or slider so it doesn't store location or anything it just draws it again when its clicked so idk if that can work in a class something like button1.update
I just have one button set and one slider but I've tried with 54 and it works still

 import processing.serial.*;

Serial myPort;
int sm = 125;
int val;       
int port = -1;
int ardport;
int contact;
int boxnumber;
String portName;
int mega = 1;
int debug;
String numba;
String pwm; 
int init = 1;



void setup(){
  size(500, 600);
  background(255);
}

void draw(){
  if(contact < 1){
  findport();
  }
  else {
    button(13, 10, 10);
    slider(13, 10, 40);
    init = 0;
    if(myPort.available() > 0){
      debug = myPort.read();
      if(debug != 10 && debug != 13) print(debug);
    }
    
}

}

void findport(){
   if(port == -1){
   for(int i = 0; i < Serial.list().length; i++){
  portName = Serial.list()[i];
  myPort = new Serial(this, portName, 57600);
  myPort.write("PING");
  delay(10);
  ardport = 0;
  if(myPort.available() > 0)  ardport = myPort.read();
 if(ardport == 'A') port = i;  
 myPort.stop();
  }
   }
   else {
     contact = 1;
     portName = Serial.list()[port];
     myPort = new Serial(this, portName, 57600);
      print("ARDUINO FOUND ON ");
      println(portName);
     myPort.clear();
     
   }
 }
 
 void slider(int num, int sx, int sy){
   if(init == 1) {
        fill(255);
        rect(sx, sy, 255, 25);
        rect(sx, sy, sm, 25);
        fill(125);
        rect(sm + sx, sy, 255 - sm, 25);
        fill(0);
        text(num, sx + 2, sy + 15);
   }
   
   if(mousePressed == true && (mouseX >= sx) && (mouseX <= sx + 255) && (mouseY >= sy) && (mouseY <= sy + 25)){
        sm = mouseX - sx;
        numba = str(num);
        if(num < 10) myPort.write(48);
        myPort.write(numba);
        myPort.write("OA");
        pwm = str(sm);
        if(sm < 10) myPort.write(48);
        if(sm < 100) myPort.write(48);
        myPort.write(pwm);
        println(sx);
        fill(255);
        rect(sx, sy, 255, 25);
        rect(sx, sy, sm, 25);
        fill(125);
        rect(sm + sx, sy, 255 - sm, 25);
        fill(0);
        text(num, sx + 2, sy + 15);
      }
   }
     
     void button(int num, int bx, int by){

  fill(255);
  rect(bx, by, 50, 14);  //13 on
  rect(bx + 60, by, 50, 14);//13 off

  fill(0);
  text(num, bx + 5, by + 12);  //13 on
  text("ON", bx + 20, by + 12);  //13 on
  text(num, bx + 65, by + 12); //13 off 
  text("OFF", bx + 80, by + 12); //13 off
  if(mousePressed == true){
    String numba = str(num);
   if((mouseX >= bx) && (mouseX <= bx + 50) && (mouseY >= by) && (mouseY <= by + 14)){
    if(num < 10) myPort.write("0");
    myPort.write(numba);
    myPort.write("O1");
   }
  if((mouseX >= bx + 60) && (mouseX <= bx + 110) && (mouseY >= by) && (mouseY <= by + 14)){
    if(num < 10) myPort.write("0");
    myPort.write(numba);
    myPort.write("O0");
  }
    
}
}

Can anyone direct me to a tutorial for like turning a function into a class?

Are you, like, a valley girl? Is this an Arduino question? Do you post questions about Arduino on the Processing forum?

`is there a procesing forum? Figured this was the best place

is there a procesing forum?

Yes, there is.