- Minimalistic car class looks like
class car{
//properties
String my_make;
String my_num;
int my_curPosx;
int my_curPosY;
int my_speed;
//building our car
car(String make, String num, int curX, int curY ){
my_make = make;
my_num = num;
my_curPosx = curX;
my_curPosY = curY;
}
void drive(int speed){
my_speed= speed;
my_curPosx = my_curPosx + my_speed;
if (my_curPosx > width) {
my_curPosx = 0;
}
}
void stop(){
my_speed = 0;
}
void display(){
stroke(0);
fill(0,0,0);
rectMode(CENTER);
rect(my_curPosx,my_curPosY,20,10);
}
}