/** A lazier student who has a favourite snack*/
// notice that we use extends Student - so everything in 
// Student is inherited by the LazierStudent.
// Student is the "super" class and LazierStudent is a 
// "subclass" of Student.
public class LazierStudent extends Student {
  /** favourite snack */
  String favouriteSnack;
  
  /** create a lazier student using the name of the student,
   *  the id of the student and the student's favourite snack.
   */
  public LazierStudent(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.favouriteSnack = s;
  }
  
  /** 
   * The lazier student sleeps instead of studying.
   */
  public String getStudyHabits() {
    return "Zzzzzzz...";
  }
  
  /** 
   * Get information about the lazier 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 LazierStudent 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() + ", " + favouriteSnack + 
      ", " + this.getStudyHabits();
  }
  
  /** A class method to test whether the object passed is a Student */
  public static boolean isStudent(Object o) {
    // here we use the new keyword "instanceof"  
    // in this case if the object o passed is an object of type Student
    // the condition will evaluate to true.
    return (o instanceof Student);
  }
  /** A class method to test whether the object passed is an AthleticStudent*/
  // We wanted to see whether an AthleticStudent could be tested from within
  // the LazierStudent class.
  public static boolean isAthletic(Object o) {
    return (o instanceof AthleticStudent); 
  }
}
