Lynk Library of Knowledge

9496 Lynk's site for housing knowledge and information for the team.


Project maintained by LynkRobotics Hosted on GitHub Pages — Theme by Jimmy McCosker

Making our own class







Example


//Simple motor class
class motor{
    //classes can have fields that store data
    int channel;                //which port is the motor connected too
    double speed = 0;           //how fast should the motor be going -1 to 1





Examples


 motor(int c){               //This is the constructor, it doesn't have a return type or void
        channel = c;            //channel doesn't get a value set until the consttuctor is run
    }
    
    int getChannel(){          //this is a "getter" method it returns a value
        return channel;
    }
    
    double getSpeed(){          
        return speed;
    }
    
    void setSpeed(double s){    //this is a "setter" method it sets a value
        speed = s;
    }




Previous Page / Home / Next Page