< previous page page_855 next page >

Page 855
// Precondition:
//     0 <= hours <= 23 && 0 <= minutes <= 59
//  && 0 <= seconds <= 59
// Postcondition:
//     hrs == hours && mins == minutes && secs == seconds
// NOTE:
//     This function MUST be called prior to
//     any of the other member functions

{
    hrs = hours;
    mins = minutes;
    secs = seconds;
}

//******************************************************************

void TimeType::Increment()

// Precondition:
//     The Set function has been invoked at least once
// Postcondition:
//     Time has been advanced by one second, with
//     23:59:59 wrapping around to 0:0:0

{
    secs++;
    if (secs > 59)
    {
        secs = 0;
        mins++;
        if (mins > 59)
        {
            mins = 0;
            hrs++;
            if (hrs > 23)
                hrs = 0;
        }
    }
}

//******************************************************************

void TimeType::Write() const

// Precondition:
//     The Set function has been invoked at least once
// Postcondition:
//     Time has been output in the form HH:MM:SS

 
< previous page page_855 next page >