@Test public void testChildCount() { Node root = new Node(); assertEquals(0, root.childCount()); Node left = new Node(); root.setLeft(left); assertEquals(1, root.childCount()); Node right = new Node(); root.setRight(right); assertEquals(2, root.childCount()); }
public int childCount() { int count = 0; if (left != null) count++; if (right != null) count++; return count; }
Node { public int childCount() { int count = 0; if (left != null) count++; if (right != null) count++; return count; } }
Node { public int childCount() { int count = 0; if (left != null) count++; if (right != null) count++; return count; } Node();  Node(Node left);  Node(Node left, Node right); }
Node { public int childCount() { int count = 0; if (left != null) count++; if (right != null) count++; return count; } Node();  Node(Node left);  Node(Node left, Node right); void setLeft(Node left); Node getLeft(); void setRight(Node right); Node getRight(); int childCount(); }
Node { public int childCount() { int count = 0; if (left != null) count++; if (right != null) count++; return count; } Node();  Node(Node left);  Node(Node left, Node right); void setLeft(Node left); Node getLeft(); void setRight(Node right); Node getRight(); int childCount();  }