Source of time.cpp


  1: // Filename: TIME.CPP
  2: // Purpose:  Implementation file corresponding to TIME.H.


  5: #include <iostream>
  6: using namespace std;


  9: #include "TIME.H"
 10: #include "PAUSE.H"


 13: Time::Time(/* in */ int hours,
 14:            /* in */ int minutes,
 15:            /* in */ int seconds)
 16: {
 17:     this->hours = hours;
 18:     this->minutes = minutes;
 19:     this->seconds = seconds;

 21:     // cout << "Now in constructor for base class Time ... \n";
 22:     // Pause(0);  cout << endl;
 23: }



 27: void Time::Set(/* in */ int hours,
 28:                /* in */ int minutes,
 29:                /* in */ int seconds)
 30: {
 31:     this->hours = hours;
 32:     this->minutes = minutes;
 33:     this->seconds = seconds;
 34: }



 38: void Time::Increment()
 39: {
 40:     seconds++;
 41:     if (seconds > 59)
 42:     {
 43:         seconds = 0;
 44:         minutes++;
 45:         if (minutes > 59)
 46:         {
 47:             minutes = 0;
 48:             hours++;
 49:             if (hours > 23)
 50:                 hours = 0;
 51:         }
 52:     }
 53: }



 57: void Time::Display() const
 58: {
 59:     if (hours < 10)
 60:         cout << '0';
 61:     cout << hours << ':';
 62:     if (minutes < 10)
 63:         cout << '0';
 64:     cout << minutes << ':';
 65:     if (seconds < 10)
 66:         cout << '0';
 67:     cout << seconds;
 68: }