/**
 * A class that extends Student.
 * Undergrads have a year-of-study (usually 1 to 4).
 *
 * An example of how we program multiple constructors for a data type class.
 *
 * @author Mark Young (A00000000)
 */
public class Undergrad extends Student {

    // ---------- Class constants ----------------------------------------- //
    public static final int DEFAULT_YEAR = 1;
    public static final String DEFAULT_PROGRAM = "Undecided";
    
    // ---------- Instance variables -------------------------------------- //
    private int year;
    private String program;


    // ---------- Constructors -------------------------------------------- //
    /** 
     * Undergrads need a name, a year, and a program.
     *
     * This is my PRIMARY constructor -- it does all the work of building this
     * Object.
     *
     * @param n the student's name
     * @param y this student's year
     * @param p this student's program
     */
    public Undergrad(String n, int y, String p) {
        super(n);       // PRIMARY constructor calls super(...)
        year = y;
        program = p;
    }

    /**
     * Can create an undergrad with just name and year (program is undecided).
     * 
     * This is a SECONDARY constructor -- it just calls the primary constrctor.
     *
     * @param n the student's name
     * @param y this student's year
     */
    public Undergrad(String n, int y) {
        this(n, y, DEFAULT_PROGRAM);  // SECONDARY constructor calls this(...)
    }

    /**
     * Can create an undergrad with just name and program (year is 1).
     *
     * This is another SECONDARY constructor -- call the primary.
     *
     * @param n the student's name
     * @param p this student's program
     */
    public Undergrad(String n, String p) {
        this(n, DEFAULT_YEAR, p);     // SECONDARY constructor calls this(...)
    }

    /**
     * Can create an undergrad with just a name (year is 1, program is 
     * undecided).
     *
     * Yet another SECONDARY constructor -- but calls one of the other 
     * secondary constructors -- which is OK.
     *
     * @param n the student's name
     */
    public Undergrad(String n) {
        this(n, 1);                   // SECONDARY constructor calls this(...)
    }

    // ---------- Getters and setters ------------------------------------- //
    /** 
     * Get this student's year of study.
     *
     * @return this student's year of study.
     */
    public int getYear() {
        return year;
    }

    /** 
     * Change this student's year of study .
     *
     * @param ny the new year of study for this student.
     */
    public void setYear(int ny) {
        // SHOULD make sure the ny is appropriate -- 1..5, for example
        this.year = ny;
    }

}
