public class Bot
{
// *************** constructors **************************
public Bot()
{
this("", 0, 0); // a constructor can
} // call another constructor
public Bot(String newName, int myX, int myY)
{
name = newName;
x = myX;
y = myX;
}
// *************** modifier methods ***********************
public void move(int xDist, int yDist)
{
this.x = this.x + xDist; // the this keyword is optional here
this.y = this.y + yDist;
}
// *************** accessor methods ***********************
public String getName()
{
return name;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public String getPosition()
{
String position = getX() + " " + getY();
return position;
}
// *************** instance fields ************************
private String name;
private int x;
private int y;
}