package schoolDirectory;

import java.io.PrintWriter;
import schoolDirectory.Entry;

public class Student extends Entry {
    // Students have two special fields
    private int year;
    private String POBox;

    public Student (String first, String last, String addr, int yr, String box) {
        super(first, last, addr);
        year = yr;
        POBox = box;
    }

    // toString method to yield nicely formatted output string
    public String toString () {
        return super.toString() + "   Class Year:  " + year
                                + "\n   Campus P. O. Box:  " + POBox + "\n";
    }

    public static void main (String [] argv) {
        // suit of tests for Student
        PrintWriter myOut = new PrintWriter(System.out, true);

        // set up three objects
        Student A = new Student ("Terry", "Walker", "walkert@math.grin.edu",
                                 1970, "off-campus");
        Student B = new Student ("Henry", "Walker", "walker@cs.grinnell.edu",
                                 1969, "Y-06");
        Student C = new Student ("Barbara", "Walker", "barbara@cs.grin.edu",
                                 2002, "12-34-56");

        // print objects
        myOut.println();
        myOut.println ("Person A:" + A);
        myOut.println ("Person B:" + B);
        myOut.println ("Person C:" + C);

        // since methods equals and comesBefore are inherited, 
        //     testing may or may not be done 

        // check comparisons
        // myOut.println();
        // myOut.println ("Results of equals");
        // myOut.println ("\tA\tB\tC");
        // myOut.println ("A\t"+A.equals(A)+"\t"+A.equals(B)+"\t"+A.equals(C));
        // myOut.println ("B\t"+B.equals(A)+"\t"+B.equals(B)+"\t"+B.equals(C));
        // myOut.println ("C\t"+C.equals(A)+"\t"+C.equals(B)+"\t"+C.equals(C));
         
        // myOut.println ("Results of comesBefore");
        // myOut.println ("\tA\tB\tC");
        // myOut.println ("A\t" + A.comesBefore(A) + "\t"
        //                + A.comesBefore(B) + "\t" + A.comesBefore(C));
        // myOut.println ("B\t" + B.comesBefore(A) + "\t"
        //                + B.comesBefore(B) + "\t"+B.comesBefore(C));
        // myOut.println ("C\t" + C.comesBefore(A) + "\t"
        //                + C.comesBefore(B) + "\t"+C.comesBefore(C));
    }
}
