summaryrefslogblamecommitdiffstats
path: root/šola/p1/dn/6/Tocka.java
blob: 8dce30b3ead9e73030546ac571fef6d110c12a71 (plain) (tree)


























                                                                                  
import java.util.*;
public class Tocka {
	private double x;
	private double y;
	public Tocka(double x, double y) {
		this.x = x;
		this.y = y;
	}
	public double vrniX() {
		return this.x;
	}
	public double vrniY() {
		return this.y;
	}
	public String toString() {
		return String.format(Locale.ROOT, "(%.2f, %.2f)", this.x, this.y);
	}
	public static Tocka izhodisce() {
		return new Tocka(0, 0);
	}
	public double razdalja(Tocka t) {
		return Math.sqrt(Math.pow(this.x-t.x, 2)+Math.pow(this.y-t.y, 2));
	}
	public double razdaljaOdIzhodisca() {
		return izhodisce().razdalja(this);
	}
}