diff --git a/src/Tree.java b/src/Tree.java index a712e81..d1c6644 100644 --- a/src/Tree.java +++ b/src/Tree.java @@ -72,15 +72,14 @@ public class Tree { Node rightChild = father.getRigthChild(); switch (father.getNode()) { case '!' : - Node child = leftChild.getLeftChild(); switch (leftChild.getNode()){ case '!': - + Node child = leftChild.getLeftChild(); appliedGreatFather(father, child); break; case '|' : - Node lc = child.getLeftChild(); - Node rc = child.getRigthChild(); + Node lc = leftChild.getLeftChild(); + Node rc = leftChild.getRigthChild(); Node notlc = new Node(null,lc,null,'!', lc.getLvl() +1); Node notrc = new Node(null,rc,null,'!', rc.getLvl() +1); @@ -93,8 +92,8 @@ public class Tree { appliedGreatFather(father, greatfather); break; case '&' : - Node lc_2 = child.getLeftChild(); - Node rc_2 = child.getRigthChild(); + Node lc_2 = leftChild.getLeftChild(); + Node rc_2 = leftChild.getRigthChild(); Node notlc_2 = new Node(null,lc_2,null,'!', lc_2.getLvl() +1); Node notrc_2 = new Node(null,rc_2,null,'!', rc_2.getLvl() +1); @@ -107,8 +106,8 @@ public class Tree { appliedGreatFather(father, greatfather_2); break; case '>' : - Node lc_3 = child.getLeftChild(); - Node rc_3 = child.getRigthChild(); + Node lc_3 = leftChild.getLeftChild(); + Node rc_3 = leftChild.getRigthChild(); Node notrc_3 = new Node(null,rc_3,null,'!', rc_3.getLvl() +1); rc_3.setFather(notrc_3); @@ -145,7 +144,9 @@ public class Tree { } else if (father.getPos() == 2) { father.getFather().setRigthChild(greatFather); greatFather.setFather(father); - } else + } else { root = greatFather; + greatFather.setFather(null); + } } } \ No newline at end of file