Another Example of Classes - 1

This is the interface for a class MyTime:
#include "Boolean.h"

class MyTime
{
  // the clients get to see/use these functions
  public:

    // set the time (hours, minutes, seconds)
    void Set(int hours, int minutes, int seconds);

    int Hours(void) const;      // get the hours
    int Minutes(void) const;    // get the minutes
    int Seconds(void) const;    // get the seconds
    void Display(void) const;   // display time on screen
    void Tick(void);            // increment time by 1 sec.

    // these functions allow us to 
    // compare MyTime objects
    Boolean isEqual(MyTime aTime) const;
    Boolean isGreater(MyTime aTime) const;

    // constructors
    MyTime(void);
    MyTime(int hours, int minutes, int seconds);

  // this data is hidden from the user
  private:

    int hours;     // represents the hours
    int minutes;   // represents the minutes
    int seconds;   // represents the seconds
};
Previous page
Next page

Back to Index
Back to Outline