gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
Stabla, dodati komentari i ideje za veliki test
[spa2-materijali.git] / Stabla / Primeri za test / StabloIOPretty.java
index 6fcc069..2df3c03 100644 (file)
@@ -6,11 +6,17 @@ import java.util.regex.Pattern;
 import org.svetovid.io.SvetovidReader;\r
 import org.svetovid.io.SvetovidWriter;\r
 \r
-/**\r
- * Format:\r
+/*\r
+ * Ova klasa sluzi za ucitavanje i snimanje stabala. Nije potrebno znati je,\r
+ * i bice data, prilikom izrade prakticnih zadataka.\r
+ *\r
+ * Ocekivani format fajla je sledeci:\r
+ *\r
  *   /-- desni\r
  * -(id) vrednost\r
  *   \-- levi\r
+ *\r
+ * Primer fajla je pretty.txt\r
  */\r
 public class StabloIOPretty implements StabloIO {\r
 \r
@@ -124,8 +130,8 @@ public class StabloIOPretty implements StabloIO {
         Stablo stablo = elements.get(minIndex);\r
         Stablo levi = formStablo(minIndex + 1, endIndex, levels, elements);\r
         Stablo desni = formStablo(beginIndex, minIndex, levels, elements);\r
-        stablo.levi = levi;\r
-        stablo.desni = desni;\r
+        stablo.setLevi(levi);\r
+        stablo.setDesni(desni);\r
         return stablo;\r
     }\r
 \r
@@ -149,9 +155,9 @@ public class StabloIOPretty implements StabloIO {
             builder.append(nullSymbol);\r
         } else {\r
             builder.append("(");\r
-            builder.append(stablo.id);\r
+            builder.append(stablo.getId());\r
             builder.append(") ");\r
-            builder.append(stablo.vrednost);\r
+            builder.append(stablo.getVrednost());\r
         }\r
         builder.append("\n");\r
     }\r
@@ -160,8 +166,8 @@ public class StabloIOPretty implements StabloIO {
         if (stablo == null) {\r
             return;\r
         }\r
-        if ((nullSymbol != null) || (stablo.desni != null)) {\r
-            appendSubtree(builder, stablo.desni, nullSymbol, separated, buildingBlocks, true, prefix);\r
+        if ((nullSymbol != null) || (stablo.getDesni() != null)) {\r
+            appendSubtree(builder, stablo.getDesni(), nullSymbol, separated, buildingBlocks, true, prefix);\r
             if (separated) {\r
                 appendEmpty(builder, buildingBlocks, prefix);\r
             }\r
@@ -172,11 +178,11 @@ public class StabloIOPretty implements StabloIO {
         if (stablo == null) {\r
             return;\r
         }\r
-        if ((nullSymbol != null) || (stablo.levi != null)) {\r
+        if ((nullSymbol != null) || (stablo.getLevi() != null)) {\r
             if (separated) {\r
                 appendEmpty(builder, buildingBlocks, prefix);\r
             }\r
-            appendSubtree(builder, stablo.levi, nullSymbol, separated, buildingBlocks, false, prefix);\r
+            appendSubtree(builder, stablo.getLevi(), nullSymbol, separated, buildingBlocks, false, prefix);\r
         }\r
     }\r
 \r
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner