package TicTacToe;

/**
 * Matthew Amdur
 * MBA
 *
 * This class models a positioner. It is used to position the squares that make up
 * the board in the correct manner. This class is never instantiated, instead the
 * method is uses to convert array indexes to position on the screen is a static
 * method.
 *
 * What is a static method? A static method is a method that can be called without
 * having to instantiate the class that contains the method. For instance, when we
 * want to call the GetPosition() method we can just go: Positioner.GetPosition().
 * We use static methods when they serve a function that many classes will use, but
 * they don't need specific references to it. For instance, the pieces don't need
 * to instantiate their own positioners, they can all use one Positioner. Rather
 * than passing it everywhere, it is easier to make a Static method. This wasn't
 * really necessary, but is a useful example of how you would use methods other than
 * private methods.
 **/

public class Positioner implements BoardSize {

  /**
   * Since the class's one method is static, we never instantiate the class. As a
   * result, the constructor is completely empty.
   */

  public Positioner() {
  }

  /**
   * This method is static. It has been defined to take an array index in the form
   * of an integer, and return the position that it corresponds to on the screen.
   * We add in SHAPE_WIDTH/2 because all of GP's positions are the middle of the 
   * shape. Since we don't want half the shape to be off the screen, we add in this
   * additional offset.
   */

  public static int GetPosition(int index) {
    return ( (index*SHAPE_WIDTH) + (index*OFFSET) + (SHAPE_WIDTH/2));
  }
}
