summaryrefslogtreecommitdiffstats
path: root/šola/p1/dn/Tocka.java
blob: 8dce30b3ead9e73030546ac571fef6d110c12a71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
	}
}