public class Ancestor
extends java.lang.Object
Constructor and Description |
---|
Ancestor() |
Modifier and Type | Method and Description |
---|---|
boolean |
initialize(java.lang.String filename)
Initialize the GenealogyTree with data
from the specified file.
|
java.lang.String |
lowestCommonAncestor(java.lang.String name1,
java.lang.String name2)
Given two names, return the lowest common ancestor
as found in the GenealogyTree.
|
static void |
main(java.lang.String[] args)
THE MAIN METHOD THAT STARTS THE APPLICATION
DO NOT CHANGE THIS METHOD
|
public java.lang.String lowestCommonAncestor(java.lang.String name1, java.lang.String name2)
(1) If name does not exist in GenealogyTree, print NAME_NOT_FOUND_MESSAGE and the corresponding name, like "Can not find name: leonhard_euler" (2) If both names are not found in GenealogyTree, do step (1) for both name1 and name2. (3) If common ancestor does not exist, return null.
name1
- of first researcher to findname2
- of second researcher to findpublic boolean initialize(java.lang.String filename)
filename
- is the name of a file with (professor->student) research pairspublic static void main(java.lang.String[] args)
args
- Command Line arguments used for file name of genealogy data