gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
Primer koriscenja skupa
authorDoni Pracner <quinnuendo@gmail.com>
Wed, 29 Apr 2015 11:25:39 +0000 (13:25 +0200)
committerDoni Pracner <quinnuendo@gmail.com>
Wed, 29 Apr 2015 11:25:39 +0000 (13:25 +0200)
kodovi/skup/PrimerSkup.java [new file with mode: 0644]

diff --git a/kodovi/skup/PrimerSkup.java b/kodovi/skup/PrimerSkup.java
new file mode 100644 (file)
index 0000000..9ae8001
--- /dev/null
@@ -0,0 +1,86 @@
+
+public class PrimerSkup {
+       
+       static void test1(){
+               Skup<String> a = new Skup<>();
+               Skup<String> 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<String> 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<Integer> parniDo10 = new Skup<>();
+               parniDo10.ubaci(2);
+               parniDo10.ubaci(4);
+               parniDo10.ubaci(6);
+               parniDo10.ubaci(8);
+               
+               Skup<Integer> neparniDo10 = new Skup<>();
+               neparniDo10.ubaci(1);
+               neparniDo10.ubaci(3);
+               neparniDo10.ubaci(5);
+               neparniDo10.ubaci(7);
+               neparniDo10.ubaci(9);
+               
+               Skup<Integer> 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<String> 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();
+
+       }
+
+}
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner