From f2920297b230738b4f4aff5f233f05e6a900a056 Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Wed, 29 Apr 2015 13:25:39 +0200 Subject: [PATCH] Primer koriscenja skupa --- kodovi/skup/PrimerSkup.java | 86 +++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 kodovi/skup/PrimerSkup.java diff --git a/kodovi/skup/PrimerSkup.java b/kodovi/skup/PrimerSkup.java new file mode 100644 index 0000000..9ae8001 --- /dev/null +++ b/kodovi/skup/PrimerSkup.java @@ -0,0 +1,86 @@ + +public class PrimerSkup { + + static void test1(){ + Skup a = new Skup<>(); + Skup b = new Skup<>(); + + a.ubaci("kvadrat"); + a.ubaci("trougao"); + a.ubaci("krug"); + + b.ubaci("kvadrat"); + b.ubaci("romb"); + b.ubaci("pravougaonik"); + + System.out.println("A:\t"+a); + System.out.println("B:\t"+b); + System.out.println("Unija:\t"+a.unija(b)); + System.out.println("Presek:\t"+a.presek(b)); + System.out.println("Razl:\t"+a.razlika(b)); + System.out.println(); + + Skup c = new Skup<>(); + c.ubaci("krug"); + c.ubaci("trougao"); + System.out.println("A:\t"+a); + System.out.println("B:\t"+b); + System.out.println("C:\t"+c); + System.out.println("Podskup:"); + System.out.println("C od A:\t"+c.podskupOd(a)); + System.out.println("C od B:\t"+c.podskupOd(b)); + System.out.println("A od A:\t"+a.podskupOd(a)); + } + + static void testBrojevi() { + Skup parniDo10 = new Skup<>(); + parniDo10.ubaci(2); + parniDo10.ubaci(4); + parniDo10.ubaci(6); + parniDo10.ubaci(8); + + Skup neparniDo10 = new Skup<>(); + neparniDo10.ubaci(1); + neparniDo10.ubaci(3); + neparniDo10.ubaci(5); + neparniDo10.ubaci(7); + neparniDo10.ubaci(9); + + Skup brojeviDo5 = new Skup<>(); + brojeviDo5.ubaci(1); + brojeviDo5.ubaci(2); + brojeviDo5.ubaci(3); + brojeviDo5.ubaci(4); + brojeviDo5.ubaci(5); + + System.out.println("Parni: "+parniDo10); + System.out.println("Neparni: "+neparniDo10); + System.out.println("Do5:"+brojeviDo5); + System.out.println("P unija N: "+parniDo10.unija(neparniDo10)); + System.out.println("Do5 presek N: "+brojeviDo5.presek(neparniDo10)); + System.out.println("Do5 razlika N: "+brojeviDo5.razlika(neparniDo10)); + } + + static void testStampa(){ + Skup a = new Skup<>(); + System.out.println(a); + + a.ubaci("kvadrat"); + + System.out.println(a); + a.ubaci("trougao"); + a.ubaci("krug"); + System.out.println(a); + } + + public static void main(String[] args) { + System.out.println("test stampe:"); + testStampa(); + System.out.println("----"); + test1(); + System.out.println("---"); + testBrojevi(); + + } + +} -- 2.25.1