// Clock class, September/October 2001
//
// Designed for Brian's Superbly Incredible and Well-Commented Non-Functional
// Clock.
//
// This is an abstract class. Both AnalogClocks and DigitalClocks extend this
// class, so a reference to a Clock can be used to refer to two completely
// different objects.

import aLibrary.*;

public abstract class Clock extends AView {
// An AnalogClock derives from AView.

  /*
   * CLASS VARIABLES
   */

  private String whoIAm;  // a short description of this clock

  /*
   * CONSTRUCTOR
   */

  public Clock(int x, int y, int w, int h) {
  // Nothing special here. Just create a new AView.
  //
  // Preconditions:
  //   Same as AView's constructor.
  //
  // Postconditions:
  //   Same as AView's constructor.

    super(x, y, w, h); // AView constructor

  }

  /*
   * ABSTRACT METHODS
   */

  public abstract void showTime(double time);
  // Declaring an abstract method that must be overridden for a non-abstract
  // class to derive from this class. This method exists so that we can call
  // showTime() on a Clock reference without knowing what type of clock it
  // actually is.

  /*
   * QUERY METHODS
   */

  public String getDescription() {
  // Returns a short description of this Clock.
  //
  // Preconditions:
  //   none.
  //
  // Postconditions:
  //   A String containing a short description of this Clock is returned.

    return whoIAm;

  }

  /*
   * UPDATE METHODS
   */

  public void setDescription(String s) {
  // Sets the description of this Clock.
  //
  // Preconditions:
  //   none.
  //
  // Postcondition:
  //   getDescription() == s

    whoIAm = s;

  }

}
