In this assignment you will read in a first name., a last name and a phone number in from a file.

    Create a class that will insert information into a tree.

    class phoneBook
    {private TreeNode Root;

    The tree is holding Person objects. It is ordered by last name. The following function should be called inside the constructor when your phone book class is constructed.

    Use a function to read in info :

    public void reader() throws IOException
    {FileReader fr = new FileReader("quiz.txt");
    BufferedReader br = new BufferedReader(fr); String phone;
    String first;

    String last;
    while ( (first = br.readLine()) != null)
    last= br.readLine();
    phone = br.readLine();
    // then put info into person class
    // then insert person into tree ordered by last name

    Your class should have a member function to insert a person into a tree sorted by last name. You should also have a function that will receive a last name and print out the phone number (if the person is not on file return null and print an appropriate message in the main program).

    To enter the file just put names and phone numbers on seperate lines. You can enter them in notepad. Save as phone.txt in same folder as your java code.

    In your client :
    phoneTree p = new phoneTree();
    String ph = p.getPhone("Smith");
    if (ph ==null)
    System.out.println("Name not on file");
    System.out.println("Number is "+ph);