/** An athletic student which is a subclass of Student */
// notice that we use extends Student - so everything in 
// Student is inherited by the AthleticStudent.
// Student is the "super" class or AthleticStudent, 
// and AthleticStudent is a "subclass" of Student.
public class AthleticStudent extends Student {
  /** every athlete has a sport */
  private String sport;
  
  /** create an athletic student using the name of the student,
   *  the id of the student and the student's sport.
   */
  public AthleticStudent(String n, int i, String s) {
    // when we use the key word "super" we are invoking
    // the constructor for the "super" class and passing
    // the necessary values.  The constructor in Student will
    // then save the n and i passed in the appropriate instance
    // variable for student.  Super, the constructor, as used
    // here must be called before any other instance variable
    // assignments are performed.
    super(n, i);
    this.sport = s;
    
  }
  
  /** 
   * Get information about the athletic student as a string.
   */
  // we have a method toString in Student.  We also have
  // a toString method here.  This method "overrides" the
  // method in the "super" class.  So this method will be called
  // for any AthleticStudent object.  However, if we wish to 
  // use the toString method from Student, we can invoke it as
  // shown here.
  public String toString() {
    // Here we invoke the toString method from the Student class
    // (our super class in this case) by using the keyword "super"
    // with the method in the superclass that we wish to invoke.
    // e.g., super.toString() - which returns a string.
    return super.toString() + ", " + sport;
  }
  
  /** A class method to test whether the object passed is an AthleticStudent*/
  public static boolean type(Object o) {
    // here we use the new keyword "instanceof"  
    // in this case if the object o passed is an object of type AthleticStudent
    // the condition will evaluate to true.
    return (o instanceof AthleticStudent);
  }
}
