< previous page page_939 next page >

Page 939
input and output. Therefore, the built-in long type is the most straightforward data representation. To implement the abstract operations of input and output we can simply use the < and >> operators.
The Time Stamp Object: The time stamp object represents a time of day. There is no built-in type we can use as a data representation, but we can use an existing classthe Time class we worked with earlier in the chapter. The complete specification of the Time class appears below.
//******************************************************************
// SPECIFICATION FILE (time.h)
// This file gives the specification of a Time abstract data type
//******************************************************************
#ifndef TIME_H
#define TIME_H

#include bool.h

class Time
{
public:
    void Set( /* in */ int hours,
              /* in */ int minutes,
              /* in */ int seconds );
        // Precondition:
        //     0 <= hours <= 23 && 0 <= minutes <= 59
        //  && 0 <= seconds <= 59
        // Postcondition:
        //     Time is set according to the incoming parameters

    void Increment();
        // Postcondition:
        //     Time has been advanced by one second, with
        //     23:59:59 wrapping around to 0:0:0

    void Write() const;
        // Postcondition:
        //     Time has been output in the form HH:MM:SS

    Time( /* in */ int initHrs,
          /* in */ int initMins,
          /* in */ int initSecs );
        // Precondition:
        //     0 <= initHrs <= 23 && 0 <= initMins <= 59
        //  && 0 <= initSecs <= 59

 
< previous page page_939 next page >