From: Doni Pracner Date: Sun, 8 Nov 2015 14:04:06 +0000 (+0100) Subject: Hash, tekst i pdf osvezeni X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=spa2-materijali.git;a=commitdiff_plain;h=0668b51c35d0655c65c35d4ea66abf7e2fff381d Hash, tekst i pdf osvezeni --- diff --git a/Hash/hash.pdf b/Hash/hash.pdf index 1b2fd1e..8a404a7 100644 Binary files a/Hash/hash.pdf and b/Hash/hash.pdf differ diff --git a/Hash/hash.txt b/Hash/hash.txt index 6c2075a..743c31c 100644 --- a/Hash/hash.txt +++ b/Hash/hash.txt @@ -285,12 +285,12 @@ Potpuna verzija bi izgledala ovako: Kancelarija k2 = (Kancelarija) o; // Prvo proveravamo broj - if (broj != other.broj) { + if (broj != k2.broj) { return false; } // A potom prezime - if (!Objects.equals(prezime, other.prezime)) { + if (!Objects.equals(prezime, k2.prezime)) { return false; } @@ -362,14 +362,23 @@ Funkcija jednakosti bi izgledala ovako: } Gadjanje o2 = (Gadjanje) o; - if (o2.rezultati.length == rezultati.length) { - for (int i = 0; i < rezultati.length; i++) { - if (o2.rezultati[i] != rezultati[i]) - return false; + // proveravamo da li je polje null pre dalje provere + if (rezultati != null && o2.rezultati != null) { + if (o2.rezultati.length == rezultati.length) { + for (int i = 0; i < rezultati.length; i++) { + if (o2.rezultati[i] != rezultati[i]){ + // cim je nesto razlicito nisu isti + return false; + } + } + // ako se sve vrednosti slazu isti su + return true; } - return true; + return false; + } else { + // vracamo da li su oba null, tj da li su jednaki + return (rezultati == null && o2.rezultati == null); } - return false; } ``` @@ -471,7 +480,11 @@ elemente matrice, na primer: if (getClass() != o.getClass()) { return false; } + + // menjamo tip da mozemo da poredimo XO o2 = (XO) o; + // posto je u ovoj klasi uvek inicijalizovano polje table + // i uvek je DIM x DIM ne moramo proveravati null for (int i = 0; i < DIM; i++) { for (int j = 0; j < DIM; j++) { if (o2.tabla[i][j] != tabla[i][j]) {