I'm trying to make a soundboard and I wanted to add a class to make it run easier and I get more points with a class if I use it.
However I get a NullPointerException and I would like to know why the problem happened. If someone can explain it to me that would be perfect.
The NullPointerException occurs when calling `sound1.run().
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
PImage soundboard;
PImage [] array= new PImage[0];
sound sound1;
Minim minim; 
AudioPlayer player;
Boolean player1= false;
void setup() {
    size(451,385);
    minim = new Minim(this);
    player = minim.loadFile("deadmau5.mp3");
    soundboard = loadImage("sb.png");
}
void draw() {
    image(soundboard,1,CENTER);
    sound1.run();
}
void mousePressed() {
    player1=!player1;
    if (player1) {
        player.play();
    } else {
        player.pause();
    player.rewind();
    }
}
class sound { 
    float x = 1;
    float y = 1;
    void run() {
        draw();
    }
    void draw() {
        rect(x,y,100,100);     
    }  
}  
One more question that I must ask: when I rewrite code, sometimes it overwrites on my current code and I want to know how to stop that, even if I use space it still overwrites the code.
Thank you guys!
 
     
    