< previous page page_941 next page >

Page 941
Testing: Testing the Time class amounts to testing each of its member functions. In the Testing and Debugging section of Chapter 15, we described at length how to test a similar class, TimeType. Time is identical to TimeType except for the absence of two member functions, Equal, and LessThan.
The Time Card Object: A time card object represents a pair of values: an employee ID number and a time stamp. The abstract operations are those we listed in our object table. There is no built-in type or existing C++ class that we can use directly to represent a time card, so we'll have to design a new class. (We sketched a TimeCard class earlier in the chapter, but it was not complete.)
Here is a possible specification of the class. Notice that we have added a new operation that did not appear in our object table: a class constructor.
//******************************************************************
// SPECIFICATION FILE (timecard.h)
// This file gives the specification of a TimeCard ADT
//******************************************************************
#ifndef TIMECARD_H
#define TIMECARD_H

#include time.h

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

    void SetID( /* in */ long idNum );
        // Precondition:
        //     idNum is assigned
        // Postcondition:
        //     ID number on the time card is idNum

    long IDPart() const;
        // Postcondition:
        //     Function value == ID number on the time card

 
< previous page page_941 next page >