import java.lang.String;
import java.util.Vector;
import java.util.Enumeration;

public class Coordinate {
	//  OVERVIEW: A Coordinate is a mutable datatype that represents a point in 2D cartesian space.
	//  A typical coordinate is <x, y>.

	/*@spec_public@*/
	private int x;
	/*@spec_public@*/
	private int y;

	Coordinate(int p_x, int p_y)
	//  EFFECTS: Constructs a new Coordinate (p_x, p_y).
	{
		x = p_x;
		y = p_y;
	}

	Coordinate(/*@non_null@*/
	Coordinate c) {
		x = c.getX();
		y = c.getY();
	}

	public int getX()
	//@ensures \result == x;
	{
		return x;
	}

	public int getY()
	//@ensures \result == y;
	{
		return y;
	}

	public void setX(int p_x)
	//@ensures this.x == p_x;
	{
		x = p_x;
	}

	public void setY(int p_y)
	//@ensures this.y == p_y;
	{
		y = p_y;
	}

	public String toString()
	//  EFFECTS:  Returns a string representation of this.
	{
		return "(" + x + ", " + y + ")";
	}

	public boolean equals(Object c)
	//  EFFECTS:  Returns coordinate if this equals Coordinate
	{
		if (c == null || !(c instanceof Coordinate)) {
			return false;
		} else {
			Coordinate b = (Coordinate) c;
			return (x == b.getX() && y == b.getY());
		}
	}

	//@requires coords.elementType == \type(Coordinate)
	//@requires coords.containsNull == false
	//@requires coords != null
	static public String outputCoordinates(Vector coords)
	//  REQUIRES:  coords != null
	//  EFFECTS:  Returns string of coordinates
	//@requires coords != null
	{
		StringBuffer res = new StringBuffer(coords.size() * 8);
		Enumeration e = coords.elements();

		while (e.hasMoreElements()) {
			Coordinate c = (Coordinate) e.nextElement();
			res.append(c.x + "," + c.y + ";");
		}

		return new String(res);
	}
}
//Copied from CS201J website - PS5 and modified