diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-12-08 20:17:50 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-12-08 20:17:50 +0100 |
commit | a7d227edcbeefbeb37df118664ac9b202bb064fd (patch) | |
tree | 6e98d5b71606db0ba68001b54fbd0c67fac8b31c /šola/p1/dn/Tocka.java | |
parent | new research (diff) | |
parent | aoc8 (diff) | |
download | r-a7d227edcbeefbeb37df118664ac9b202bb064fd.tar r-a7d227edcbeefbeb37df118664ac9b202bb064fd.tar.gz r-a7d227edcbeefbeb37df118664ac9b202bb064fd.tar.bz2 r-a7d227edcbeefbeb37df118664ac9b202bb064fd.tar.lz r-a7d227edcbeefbeb37df118664ac9b202bb064fd.tar.xz r-a7d227edcbeefbeb37df118664ac9b202bb064fd.tar.zst r-a7d227edcbeefbeb37df118664ac9b202bb064fd.zip |
Diffstat (limited to 'šola/p1/dn/Tocka.java')
-rw-r--r-- | šola/p1/dn/Tocka.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/šola/p1/dn/Tocka.java b/šola/p1/dn/Tocka.java new file mode 100644 index 0000000..8dce30b --- /dev/null +++ b/šola/p1/dn/Tocka.java @@ -0,0 +1,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); + } +} |