public class Piece
{
  private String description;
  private int whereAmI;
  private int order;
  private int turns;
  private int modulus;

  public Piece(String desc, int order)
  {
    description = desc;
    this.order = order;
    this.turns = 0;
    this.modulus = 0;
    this.whereAmI = 0;
  }


  public Piece(String desc, int order, int modulus)
  {
    description = desc;
    this.order = order;
    this.modulus = modulus;
    if (modulus < 0)
      modulus = -modulus;
    whereAmI = 0;
    turns = 0; 
  }

  public Piece(String desc, int order, int whereAmI, int modulus)
  {
    description = desc;
    this.order = order;
    this.whereAmI = whereAmI;
    this.modulus  = modulus;
    if (modulus < 0)
      modulus = -modulus;
    turns = 0;
  }

  public int move(int howFar)
  {
    if (modulus < 2)
      whereAmI += howFar;
    else
      whereAmI = (whereAmI + howFar) % modulus;
    return whereAmI;
  }

  public int getOrder()
  {
    return order;
  }

  public int getWhere()
  {
    return whereAmI;
  }

  public String toString()
  {
    return description + " at " + this.getWhere(); 
  }

  public static void main(String args[])
  {
    Piece p1, p2, p3;
    p1 = new Piece("A red pawn ", 1);
    p2 = new Piece("A green pawn ", 2, 5);
    p3 = new Piece("A yellow pawn ", 7, 3, 0);

    System.out.println(p1 + " " + p2 + " " + p3);
    p1.move(8);
    p2.move(8);
    p3.move(8);
    System.out.println(p1 + " " + p2 + " " + p3);
  }
}
 
  

