import java.util.Scanner;

/**
 * A program to demonstrat various bits of inheritance.
 *
 * @author Mark Young (A00000000)
 */
public class TestPeople {

    public static void main(String[] args) {
        // simple inheritance
        introduceSelf();
        testPersonClass();
        testStudentClass();
        testUndergradClass();
        testGradStudentClass();
        
        // public and private methods

        // Overriding

    }

    private static void introduceSelf() {
        System.out.println("\n\n"
                + "Testing Inheritance using Person and Student\n"
                + "--------------------------------------------\n\n"
                + "Inheritance is when one class 'extends' another.\n"
                + "In this example Student extends Person.");
        pause();
    }

    private static void testPersonClass() {
        // create Persons and do peron-y things with them
        System.out.println("Creating Persons Bob and Cathy");
        Person bob = new Person("Bob");
        Person cathy = new Person("Cathy");
        System.out.println("Persons have names:");
        System.out.println("\tbob.getName() returns " + bob.getName());
        System.out.println("\tcathy.getName() returns " + cathy.getName());
        pause();
    }

    private static void testStudentClass() {
        // create Persons and do peron-y things with them
        System.out.println("Creating Students Alexander and Djenaba");
        Student alex = new Student("Alexander");
        Student djen = new Student("Djenaba");
        System.out.println("Students have A-Numbers:");
        System.out.println("\talex.A_NUMBER is " + alex.A_NUMBER);
        System.out.println("\tdjen.A_NUMBER is " + djen.A_NUMBER);
        pause();

        // do some grade stuff
        System.out.println("Students have grades:");
        alex.setGrade(80);
        djen.setGrade(85);
        System.out.println("\talex.getGrade() is " + alex.getGrade());
        System.out.println("\tdjen.getGrade() is " + djen.getGrade());
        pause();

        // do some Person stuff
        System.out.println("Students are Persons, and Persons have names:");
        System.out.println("\talex.getName() is " + alex.getName());
        System.out.println("\tdjen.getName() is " + djen.getName());
        pause();
    }

    private static void testUndergradClass() {
        // create Persons and do peron-y things with them
        System.out.println("Creating Undergrads Ellen and Frank");
        Undergrad ellen = new Undergrad("Ellen", 3);
        Undergrad frank = new Undergrad("Frank");
        System.out.println("Undergrads have years:");
        System.out.println("\tellen.getYear() is " + ellen.getYear());
        System.out.println("\tfrank.getYear() is " + frank.getYear());
        pause();

        // do some grade stuff
        System.out.println("Undergrads are Students, and so:");
        ellen.setGrade(70);
        frank.setGrade(75);
        System.out.println("\tellen.A_NUMBER is " + ellen.A_NUMBER);
        System.out.println("\tfrank.A_NUMBER is " + frank.A_NUMBER);
        System.out.println("\tellen.getGrade() is " + ellen.getGrade());
        System.out.println("\tfrank.getGrade() is " + frank.getGrade());
        pause();

        // do some Person stuff
        System.out.println("Undergrads are Students, "
                + "and Students are Persons, so:");
        System.out.println("\tellen.getName() is " + ellen.getName());
        System.out.println("\tfrank.getName() is " + frank.getName());
        pause();
    }

    private static void testGradStudentClass() {
        // create Persons and do peron-y things with them
        System.out.println("Creating GradStudents geety and harry");
        GradStudent geety = new GradStudent("Geety", "BSc");
        GradStudent harry = new GradStudent("Harry", "BSc, MMath");
        System.out.println("GradStudents have previous degrees:");
        System.out.println("\tgeety.getPreviousDegree() is " 
                + geety.getPreviousDegree());
        System.out.println("\tharry.getPreviousDegree() is " 
                + harry.getPreviousDegree());
        pause();

        // do some grade stuff
        System.out.println("Undergrads are Students are Persons....");
        geety.setGrade(90);
        harry.setGrade(95);
        System.out.println("\tgeety.A_NUMBER is " + geety.A_NUMBER);
        System.out.println("\tharry.A_NUMBER is " + harry.A_NUMBER);
        System.out.println("\tgeety.getGrade() is " + geety.getGrade());
        System.out.println("\tharry.getGrade() is " + harry.getGrade());
        System.out.println("\tgeety.getName() is " + geety.getName());
        System.out.println("\tharry.getName() is " + harry.getName());
        pause();
    }

    public static void pause() {
        Scanner kbd = new Scanner(System.in);
        System.out.print("\nPress enter...");
        kbd.nextLine();
        System.out.println("\n\n\n\n");
    }

}
