title: Family Tree in java
body: <p>I need to create a java program that can create a family tree in java. The program reads an input file in below format:</p>
  
  <pre><code>A is father of B
  B is father of C
  A is father of D
  :
  :
  </code></pre>
  
  <p>What I need to do is to create a family tree or whatever that seems logical. Then JUnit tests will run on my program, asking to return true or false like:
  B is child of A, A is an ancestor of E......</p>
  
  <p>Plus, I need to traverse the tree from left to right, and show hierarchy like:
  A B C.....</p>
  
  <p>I have thought of some logic, though I am new to Java. I have created a Person class, this has elements: Name, Left of Person type and Right of person type:</p>
  
  <pre><code>class Person {
  
      String name;
      Person left;
      Person right;
  }
  </code></pre>
  
  <p>Plus I have added getters, setters and a constructor.</p>
  
  <p>Then I read the file and create one person as:</p>
  
  <pre><code>BufferedReader br = new BufferedReader(new FileReader(new File(path)));
  String names[] = br.readLine().split(" ");
  Person p = new Person(names[0]);
  p.setLeft(new Person(names[4]));
  </code></pre>
  
  <p>I am totally confused at this stage and would benefit some guidance.
  Thanks in advace</p>