// Arup Guha
// 2/24/2026
// Position class to track a position on a Cartesian grid.
// Edited on 3/8/2026 for Abstract class lecture
// Will probably remove redundancy in the future.

public class Position {

	private int x;
	private int y;
	
	// Creates a Position at (myx, myy).
	public Position(int myx, int myy) {
		x = myx;
		y = myy;
	}
		
	// Accessors...
	public int getX() {
		return x;
	}
	
	public int getY() {
		return y;
	}
	
	// Negates this position.
	public void negate() {
		x = -x;
		y = -y;
	}
	
	// Returns true iff this position is in the specified bounds.
	public boolean inbounds(int minX, int maxX, int minY, int maxY) {
		return x >= minX && x <= maxX && y >= minY && y <= maxY;
	}
	
	// Returns true iff this and other are the same Position.
	public boolean equals(Position other) {
		return x == other.x && y == other.y;
	}
	
	// Moves this Position by an offset of other.
	public void moveBy(Position other) {
		x += other.x;
		y += other.y;
	}
	
	// Returns where we would be if we moved this position by other.
	public Position wouldMoveBy(Position other) {
		return new Position(x+other.x, y+other.y);
	}
	
	// String representation of the object.
	public String toString() {
		return "("+x+", "+y+")";
	}
}