Source of Undergrad.java


  2: /**
  3:  * A class that extends Student.
  4:  *
  5:  * @author Mark Young (A00000000)
  6:  */
  7: public class Undergrad extends Student {
  8:     
  9:     /** 
 10:      * Undergrads have a year-of-study (usually 1 to 4) 
 11:      */
 12:     private int year;

 14:     /** 
 15:      * Undergrads need a name and a year 
 16:      *
 17:      * @param name this Undergrad's name
 18:      * @param year this Undergrad's year
 19:      */
 20:     public Undergrad(String name, int year) {
 21:         super(name);
 22:         this.year = year;
 23:     }

 25:     /** 
 26:      * Create a first year Undergrad.
 27:      *
 28:      * @param name this Undergrad's name
 29:      */
 30:     public Undergrad(String name) {
 31:         this(name, 1);
 32:     }

 34:     /** 
 35:      * return this student's year of study 
 36:      *
 37:      * @return this student's year of study 
 38:      */
 39:     public int getYear() {
 40:         return year;
 41:     }

 43:     /** 
 44:      * Change this student's year of study 
 45:      *
 46:      * @param newYear this Student's new year of study
 47:      */
 48:     public void setYear(int newYear) {
 49:         this.year = newYear;
 50:     }

 52: }