#ifndef BALTIME_H #define BALTIME_H // baltime.h Interface file for really basic BAL type classes /******************************************************************************* // MODULE NAME: TimeType // INTERFACE FILE: baltime.h // IMPLEMENTATION FILE: baltime.cpp // // PURPOSE: To create a TimeType useful in an implementation of the BAL program, // allowing the user to create a new object, change its value, determine if it // contains an invalid or default value, and print the current or default value // // FUNCTIONS: Name Purpose // TimeType Parameterless Constructor // isValid Tests whether the time is valid // isDefault Tests whether the time is a default value // Equals Show whether this time === another // LessThan Show whether this time < another // GreaterThan Show whether this time > another // Print Print the current value of the object // Default Print the default value of the object // valueIs Print the current value of the object // Limits Show the limits on the object // Store Set the time as indicated by 2 ints // Store Set the time as indicated by a string // Reset Change the time to its default value // // AUTHOR: Amy Langill *2B DATE: 3/20/1999 *******************************************************************************/ #include // for strings & string functions #include // for conversions w/stringstreams using namespace std; const int DEFAULT_HOURS=99; // Named constants for storing default values const int DEFAULT_MINUTES=99; // for the elements of a TimeType variable const int HOURS_MAX=23; // The logical limits on time when displayed in const int HOURS_MIN=0; // military style const int MINUTES_MAX=59; // const int MINUTES_MIN=0; // const int TIME_FLD_WDTH=2; // maximum width of a field in a TimeType variable const int TIME_WIDTH=5; // Total width of a TimeType object class TimeType { public: // Constructors TimeType(); // parameterless constructor // Observers bool isValid(); // is the time actually possible? bool isDefault(); // Does the object contain the default values? bool Equals(TimeType someTime); // For comparing different times bool LessThan(TimeType someTime); // bool GreaterThan(TimeType someTime); // string Print(); // for outputting time information as a string string Default(); // prints out default time as formatted string string valueIs(); // output time information as a string string Limits(); // Transformers void Set(int hoursValue,int minutesValue); // Set it to a certain time void Store(string newTime); // set it to a certain time void Reset(); // Store the default values into TimeType variable private: // Data members int hours; // Hour of the day int minutes; // Minute of the hour }; #endif