//----------------------------------------------------------------------
//  SPECIFICATION FILE (newfrac.h)
//  This module exports a FracType class with two operator functions,
//  operator* and operator==.
//  It also adds a default (parameterless) constructor
//  and exports operator<< and operator>> for stream I/O.
//----------------------------------------------------------------------
#include "bool.h"
#include <iostream.h>

class FracType {
public:
    float FloatEquiv() const;
        // POST: FCTVAL == float equivalent of this fraction

    void Simplify();
        // POST: Fraction is reduced to lowest terms. (No integer > 1
        //       evenly divides both the numerator and denominator)

    FracType operator*( /* in */ FracType frac2 ) const;
        // PRE:  This fraction and frac2 are in simplest terms
        // POST: FCTVAL == this fraction * frac2  (fraction
        //                 multiplication), reduced to lowest terms
        // NOTE: Numerators or denominators of large magnitude
        //       may produce overflow

    Boolean operator==( /* in */ FracType frac2 ) const;
        // PRE:  This fraction and frac2 are in simplest terms
        // POST: FCTVAL == TRUE, if this fraction == frac2 (numerically)
        //              == FALSE, otherwise

    FracType( /* in */ int initNumer,
              /* in */ int initDenom );
        // Constructor
        // PRE:  Assigned(initNumer)  &&  initDenom > 0
        // POST: Fraction has been created and can be thought of
        //       as the fraction  initNumer / initDenom
        // NOTE: (initNumer < 0) --> fraction is a negative number

    FracType();
        // Constructor
        // POST: Fraction has been created and can be thought of
        //       as the fraction  0 / 1

//friends:
    friend ostream& operator<<( /* inout */ ostream& someStream,
                                /* in */    FracType frac       );
        // PRE:  someStream is a valid stream object
        // POST: The value of frac has been displayed as:
        //            <numerator> / <denominator>
        //       with no blanks
        //    && FCTVAL == address of someStream

    friend istream& operator>>( /* inout */ istream&  someStream,
                                /* out */   FracType& frac       );
        // PRE:  someStream is a valid stream object
        //    && Client code has already prompted the user for input
        // POST: User has typed in a numerator (call it newNumer), then
        //          a slash, then a denominator (call it newDenom)
        //    && frac can be thought of as
        //          the fraction  newNumer / newDenom
        //    && newDenom > 0
        //    && FCTVAL == address of someStream
private:
    int numer;
    int denom;
};


