#ifndef BALFLOAT_H #define BALFLOAT_H // bafloat.h Interface file for the LimitFloat class /******************************************************************************* // MODULE NAME: LimitFloat // INTERFACE FILE: balfloat.h // IMPLEMENTATION FILE: balfloat.cpp // // PURPOSE: To provide an float type useful for the BAL program which can store // float values, prfloating width, and logical limits upon those floats. To // allow the client to store new values or new limits, to test the validity of // a stored value against the current limits, to report on the current value of // the float, to print in a formatted string the current value of the float, to // print the default value for the float, & to reset the value or limits or both // of the float // // FUNCTIONS: Name Purpose // LimitFloat Parameterless constructor // LimitFloat Constructor w/specified field width // LimitFloat Constructur w/ field width, limit type, limit // value // LimitFloat Constructor w/ field width, 2 limit types, 2 // limit values // isValid Indicate whether the value stored in the // LimitFloat conforms to the limits on the object // isDefault Inidicate whether the default value for that // object is currently stored in the object // LessThan Test whether this object ought to precede // another of the same class // Equals Test whether this object has the same value as // another of the same class // GreaterThan Test whether this object ought to follow another // of the same class // Print Create a string with the appropriate width that // contains the current value of the object // Default Create a string with the appropriate width that // contains the default value for the object // valueIs Return the value currently stored in the object // Limits Create a string that tells what the contstraints // are on this object // setLimit Sets one limit to user-specified values, and the // other limit to the default (NO_LIMIT) // setLimit Set both limits and limit types to user- // specified values // SetSize Change the printing width of the object // Store Store a new float value into the value // ResetValue Change the current value of the object to the // default value for this object // ResetLimits Change the limits on this object to the default // limits (NO_LIMIT) for this object // Reset Change the value and limits of this object to // their default values // // // AUTHOR: Amy Langill *2B Date: 3/20/1999 *******************************************************************************/ #include // For strings & string functions #include // for string streams #include "ballimits.h" // For LimitType enums & limit constants using namespace std; const int DEFAULT_FLT_SIZE=4; // Default width of the float when printed class LimitFloat { public: // Constructors: LimitFloat(); // Paramterless constructor LimitFloat(int width); // Constructor w/specified field width LimitFloat(LimitType comparison, float Limit, // Constructor with limit type int width); // limit value & field width LimitFloat(LimitType compare1, float Limit1, // Constructor with 2 limit types LimitType compare2, float Limit2, // both limit values & field int width); // size // Observers: bool isValid(); // Is the value OK? bool isDefault(); // Is the value the default? bool LessThan(LimitFloat another); // Is this LimitFloat < another? bool Equals(LimitFloat another); // Is this LimitFloat == another? bool GreaterThan(LimitFloat another); // Is this LimitFloat > another? string Print(); // Prints the current value with the right field width string Default(); // Prints the default value with the right field width string Limits(); // Prints the current limits on this object float valueIs(); // What is the currently stored value? // Transformers: void setLimit(LimitType comparison,float Limit); // Change the first limit // to these values void setLimit(LimitType compare1,float Limit1, // Change the limits to these LimitType compare2,float Limit2); // values void SetSize(int width); // Change the object's print size void Store(float newValue); // Store a new float into the object's value void ResetValue(); // Set the value to the default value void ResetLimits(); // Set both limits to the default (NO_LIMIT) void Reset(); // Set the value and limits to their default values private: // Data members float value; LimitType lowCompare; float lowerLimit; LimitType topCompare; float upperLimit; int size; }; #endif