//a class can be called to perform tasks over and over without having to do procedural programming (where the code is read one line at a time). This save programmers tons of time.
public class ninja { //public means it is accessible from anywhere
// local variables are placeholders of data in this local class called ninja.
String color; //string type means it will hold letters,number, and other things.
integer numNinja; //integer type means it can hold number positive or negative, but not decimals.
//constructor that is public(accessible from anywhere in the code).
//a constructor is a place holder for the methods being called in this class ninja
// methods are just code statements that perform an action.
public ninja(){
}
//setter methods that set up what the variables will have
//void means they don't return a value, it only sets data into the two variables
//this method is called setColor
public void setColor(String _color){
color = _color;
}
//this method is called setNumNinja
public void setNumNinja(integer _numNinja){
numNinja = _numNinja
}
//getter methods that can be called anywhere in the code to get the data from the variables
//this method is called getColor
public String getColor(){
return color; //return statement
}
//this method is called getNumNinja
public Integer getNumNinja(){
return numNinja; //return statement
}
^^^^everything is set now you want to be able to use this class. Here is how it is done:
//create an instance of an object. in this case it is called ninja. lets create some real ninjas in code.
ninja n = new ninja();
^^^this statement creates the object n on the left side. on the right side the new instance of class ninja is created. n object equals a new class ninja instance







