//*******************************************************************
//
//   Messages2.java          In Text          Application
//
//   Authors:  Lewis and Loftus
//
//   Classes:  Messages2
//             Thought
//             Advice
//
//*******************************************************************


//-------------------------------------------------------------------
//
//  Class Messages2 contains the driver of a program that
//  demonstrates the use of a polymorphic reference.
//
//  Methods:
//
//     public static void main (String[] args)
//
//-------------------------------------------------------------------

class Messages2 {

   //===========================================================
   //  Prints a message from two objects, then uses a
   //  polymorphic reference to print one of them again.
   //===========================================================
   public static void main (String[] args) {

      Thought territory = new Thought();
      Advice cliche = new Advice();

      territory.message();
      cliche.message();

      territory = cliche;
      territory.message();

   }  // method main

}  // class Messages

//-------------------------------------------------------------------
//
//  Class Thought contains a method that is overridden in a derived
//  class.
//
//  Methods:
//
//     public void message()
//
//-------------------------------------------------------------------
class Thought {

   //===========================================================
   //  Prints a message.
   //===========================================================
   public void message() {

      System.out.println ("Some people get lost in thought " +
                          "because it's unfamiliar territory.");
      System.out.println();

   }  // method message

}  // class Thought

//-------------------------------------------------------------------
//
//  Class Advice overrides the message method.
//
//  Methods:
//
//     public void message()
//
//-------------------------------------------------------------------
class Advice extends Thought {

   //===========================================================
   //  Prints a message.
   //===========================================================
   public void message() {

      System.out.println ("Avoid cliches like the plague.");
      System.out.println();

   }  // method message

}  // class Advice


