summaryrefslogtreecommitdiffstats
path: root/šola/p1/dn/6/Tocka.java
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-12-17 23:17:03 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-12-17 23:17:03 +0100
commitb0324289066876915efb84a133eca039d8e8c8ee (patch)
tree76b06718de422ed0e5aacbd76c611ee4f82ff526 /šola/p1/dn/6/Tocka.java
parentaoc11 (diff)
downloadr-b0324289066876915efb84a133eca039d8e8c8ee.tar
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.gz
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.bz2
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.lz
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.xz
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.zst
r-b0324289066876915efb84a133eca039d8e8c8ee.zip
Diffstat (limited to 'šola/p1/dn/6/Tocka.java')
-rw-r--r--šola/p1/dn/6/Tocka.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/šola/p1/dn/6/Tocka.java b/šola/p1/dn/6/Tocka.java
new file mode 100644
index 0000000..8dce30b
--- /dev/null
+++ b/šola/p1/dn/6/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);
+ }
+}