public void printChildren() { System.out.print("Children: "); if (children.isEmpty()) System.out.print("null"); else { for (int i = 0; i < children.size(); ++i) { Node child = children.get(i); System.out.print(child.getName() + "\t"); } } System.out.println(); }
public void printSiblings() { if (parent == null) System.out.println("Siblings: " + parent); else { System.out.print("Siblings: "); ArrayList<Node> siblings = parent.getChildren(); if (siblings.isEmpty()) System.out.print("null"); else { for (int i = 0; i < siblings.size(); ++i) { Node child = siblings.get(i); if (!child.getName().equals(name)) System.out.print(child.getName() + "\t"); } } System.out.println(); } }
public void printParent() { if (parent == null) System.out.println("Parent: " + parent); else System.out.println("Parent: " + parent.getName()); }