//File:	Pt.java
import java.text.DecimalFormat;
public class Pt
{
	private double x;
	private double y;
	
	//Constructors
	public Pt(double a, double b)
	{
		x=a;
		y=b;
	}
	
	public Pt()
	{
		x=0;
		y=0;
	}
	
	//Accessors
	public double getX()
	{
		return x;
	}
	
	public double getY()
	{
		return y;
	}
	
	//the default format for a Pt object
	public String toString()
	{
		return "(" + x + ", " + y + ")";
	}
	
	//The following returns the distance formatted to two places after the decimal point
	public String formattedDistance(Pt p)
	{
		DecimalFormat precision2 = new DecimalFormat("0.00");
		return precision2.format(distance(p));
	}
	
	public double distance(Pt p)
	{
		//The following implements the Pythagorean Theorem; i.e., c squared = a squared + b squared
		return 	Math.sqrt(Math.pow((p.x-this.x),2) + Math.pow((p.y-this.y),2));
	}
	//NOTE:	this.x is equivalent to x.  The keyword this refers to the current object.
}
