//*******************************************************************
//
//   School.java          In Text          Application
//
//   Authors:  Lewis and Loftus
//
//   Classes:  School
//             Student
//             Grad_Student
//
//*******************************************************************


//-------------------------------------------------------------------
//
//  Class School contains the driver of a program that demonstrates
//  inheritance and the interaction between derived classes.
//
//  Methods:
//
//     public static void main (String[] args)
//
//-------------------------------------------------------------------

class School {

   //===========================================================
   //  Creates two objects and invokes their methods.
   //===========================================================
   public static void main (String[] args) {

      Student sammy = new Student ("Sammy", 5);
      Grad_Student pete = new Grad_Student ("Pete", 3,
         "Teaching Assistant", 8.75);

      sammy.info();

      System.out.println();

      pete.info();
      pete.support();

   }  // method main

}  // class School

//-------------------------------------------------------------------
//
//  Class Student represents one student that is currently taking a
//  certain number of courses.
//
//  Constructors:
//
//     public Student (String student_name, int classes)
//
//  Methods:
//
//     public void info ()
//
//-------------------------------------------------------------------
//  Represents one student that is currently taking a certain
//  number of courses.
class Student {

   protected String name;
   protected int num_courses;

   //===========================================================
   //  Sets up a student with the specified name and number
   //  of classes.
   //===========================================================
   public Student (String student_name, int classes) {

      name = student_name;
      num_courses = classes;

   }  // constructor Student

   //===========================================================
   //  Prints a message with the basic student information.
   //===========================================================
   public void info () {

      System.out.println ("Student name: " + name);
      System.out.println ("Number of courses: " + num_courses);

   }  // method info

}  // class Student

//-------------------------------------------------------------------
//
//  Class Grad_Student represents a graduate student, who may
//  receive financial support.
//
//  Constructors:
//
//     public Grad_Student (String student_name, int classes,
//               String support_source, double hourly_rate)
//
//  Methods:
//
//     public void support ()
//
//-------------------------------------------------------------------

class Grad_Student extends Student {

   private String source;
   private double rate;

   //===========================================================
   //  Sets up a gradate student using Student's constructor to
   //  handle the name and number of classes.
   //===========================================================
   public Grad_Student (String student_name, int classes,
             String support_source, double hourly_rate) {

      super (student_name, classes);

      source = support_source;
      rate = hourly_rate;

   }  // constructor Grad_Student

   //===========================================================
   //  Prints a message about the financial support of the
   //  graduate student.
   //===========================================================
   public void support () {

      System.out.println ("Support source: " + source);
      System.out.println ("Hourly pay rate: " + rate);

   }  // method support

}  // class Grad_Student


