|
|
|
|
|
|
|
C++ class declaration requirement we now choose a data representation. The simplest representation for a date is three int valuesone each for the month, day, and year. Here, then, is the specification file containing the DateType class declaration (along with the declaration of the RelationType enumeration type). |
|
|
|
|
|
|
|
|
//******************************************************************
// SPECIFICATION FILE (datetype.h)
// This file gives the specification of a DateType abstract data
// type and provides an enumeration type for comparing dates
//******************************************************************
enum RelationType {BEFORE, SAME, AFTER};
class DateType
{
public:
void Set( /* in */ int newMonth,
/* in */ int newDay,
/* in */ int newYear );
// Precondition:
// 1 <= newMonth <= 12
// && 1 <= newDay <= maximum no. of days in month newMonth
// && 1582 < newYear
// Postcondition:
// Date is set according to the incoming parameters
int Month() const;
// Postcondition:
// Function value == this date's month
int Day() const;
// Postcondition:
// Function value == this date's day
int Year() const;
// Postcondition:
// Function value == this date's year
void Print() const;
// Postcondition:
// Date has been output in the form
// month day, year
// where the name of the month is printed as a string |
|
|
|
|
|