From 787a189b5773928bfcb09173c4407475ea6b0219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Wed, 6 Dec 2023 20:09:53 +0100 Subject: DN06 etc --- "\305\241ola/p1/dn/Tocka.java" | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "\305\241ola/p1/dn/Tocka.java" (limited to 'šola/p1/dn/Tocka.java') diff --git "a/\305\241ola/p1/dn/Tocka.java" "b/\305\241ola/p1/dn/Tocka.java" new file mode 100644 index 0000000..8dce30b --- /dev/null +++ "b/\305\241ola/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); + } +} -- cgit v1.2.3