From a6434f49fd130bb9b05ff103b04f9b9c9ccb3713 Mon Sep 17 00:00:00 2001 From: Ivan Pribela Date: Fri, 8 Dec 2017 20:52:45 +0100 Subject: [PATCH] Lavirint, objedinjeno resenje, doteran ispis --- .../SuperKomplikovanoResenje/Lavirint.java | 2 +- .../LavirintProgram.java | 27 +++++++++---------- .../SuperKomplikovanoResenje/Mapa.java | 5 ++-- .../SuperKomplikovanoResenje/Put.java | 3 ++- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Lavirint.java b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Lavirint.java index 5b84e5a..7f18f3f 100644 --- a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Lavirint.java +++ b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Lavirint.java @@ -15,7 +15,7 @@ public class Lavirint { private Put optResenje; // Ucitava mapu iz datog fajla i stampa je na ekran - Lavirint(String imeFajla) { + public Lavirint(String imeFajla) { m = new Mapa(imeFajla); m.stampaj(); } diff --git a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/LavirintProgram.java b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/LavirintProgram.java index e622674..328f62c 100644 --- a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/LavirintProgram.java +++ b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/LavirintProgram.java @@ -31,37 +31,36 @@ public class LavirintProgram { System.out.println("Unesite izbor 1-4:"); int op = Svetovid.in.readInt(); - Lavirint l = new Lavirint(fajl); - Put r; + Lavirint lavirint = new Lavirint(fajl); + Put put; - if (l != null) { + if (lavirint != null) { switch (op) { case 1: - if (l.postojiPut(0, 0)) { + if (lavirint.postojiPut(0, 0)) { System.out.println("Postoji put"); } else { System.out.println("Ne postoji put"); } break; case 2: - l.nadjiPut(0, 0); + lavirint.nadjiPut(0, 0); break; case 3: - r = l.najkraciPut(0, 0); - if (r != null) { - r.stampaj(); + put = lavirint.najkraciPut(0, 0); + if (put != null) { + put.stampaj(); } else { - System.out.println("Nema resenja"); + System.out.println("Ne postoji put"); } break; case 4: - r = l.najvrednijiPut(0, 0); - if (r != null) { - r.stampaj(); - System.out.println("Vrednost puta: " + r.getVrednost()); + put = lavirint.najvrednijiPut(0, 0); + if (put != null) { + put.stampaj(); } else { - System.out.println("Nema resenja"); + System.out.println("Ne postoji put"); } break; default: diff --git a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Mapa.java b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Mapa.java index a39c662..091f37d 100644 --- a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Mapa.java +++ b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Mapa.java @@ -78,10 +78,11 @@ public class Mapa { public void stampaj() { if (visina != 0 && sirina != 0) { - System.out.println(visina + " " + sirina); + System.out.println(); + System.out.println("Mapa sirine " + sirina + " i visine " + visina); for (int j = 0; j < visina; j++) { for (int i = 0; i < sirina; i++) { - System.out.print(mat[i][j] + "\t"); + System.out.printf("%5d", mat[i][j]); } System.out.println(); } diff --git a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Put.java b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Put.java index e942883..9ecf9a1 100644 --- a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Put.java +++ b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Put.java @@ -56,7 +56,8 @@ public class Put { // Stampa put public void stampaj() { - System.out.println(getLength()); + System.out.println(); + System.out.println("Put duzine " + getLength() + " i vrednosti " + getVrednost()); for (int i = 0; i < getLength(); i++) { System.out.println(polja.get(i)); } -- 2.25.1