A class is a blueprint for making an object.
Swarm models, like any Java program, are described using one or more classes.
Here's an example of a simple class:
public class Position {
public int x;
public int y;
public Position (int x, int y) {
this.x = x;
this.y = y;
}
public int getDimensionality () {
return 2;
}
}
This class has two variables (x and y), a method for creating itself (Position), and a method that returns number of dimensions in the class.
When a method has the same name as the class, that method is called a constructor. It is possible to have multiple constructors, each that create the object in a different way according to the appropriate use of different parameters.
The modifier public means that an item is visible outside of the class.