/* rational.h
 * This file is a variation of the rational.h file written by:
 * // Authors: James P. Cohoon and Jack W. Davidson
 * // Date: 7/15/96
 * // Version: 1.0b
 */

#ifndef RATIONAL_H_
#define RATIONAL_H_

#include <iostream>
using namespace std;

// Rational ADT: class description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
class Rational {
 private: // data members
   int numeratorValue;
   int denominatorValue;
 public: // member functions
   // constructors
   Rational();
   Rational(int numer, int denom = 1);
   // some arithmetic and stream operators
   Rational operator+(const Rational&) const;
   Rational operator*(const Rational&) const;
   // inserting a Rational
   friend ostream& operator<<(ostream& sout, const Rational& r) {
	   if (r.denominatorValue == 1)
		  sout << r.numeratorValue;
	   else
	      sout << r.numeratorValue << '/' << r.denominatorValue;
	   return sout;
   }

   // extracting a Rational
   friend istream& operator>>(istream& sin, Rational& r) {
	char slash;
	sin >> r.numeratorValue >> slash >> r.denominatorValue;
	return sin;
   }
};

#endif



