#ifndef __RATIONAL_H__ #define __RATIONAL_H__ #include "Number.h" #include using std::istream; using std::ostream; class Rational : public Number { public: enum DISPLAY { FRACTIONAL, FLOATING_POINT }; private: int num; int den; static DISPLAY display_style; void simplify(); static int gcd(const int, const int); void init(const int, const int); public: Rational(); Rational(const Rational& obj); Rational(const int, const int); void setNums(const int, const int); int getNumerator() const; int getDenominator() const; static void setDisplayStyle(const DISPLAY); Rational& operator-=(const Rational& rhs); Rational& operator+=(const Rational& rhs); Rational& operator*=(const Rational& rhs); Rational& operator/=(const Rational& rhs); Rational& operator=(const Rational& rhs); const Rational operator+(const Rational& rhs) const; const Rational operator-(const Rational& rhs) const; const Rational operator*(const Rational& rhs) const; const Rational operator/(const Rational& rhs) const; bool operator==(const Rational& rhs) const; bool operator!=(const Rational& rhs) const; bool operator<(const Rational& rhs) const; bool operator<=(const Rational& rhs) const; bool operator>(const Rational& rhs) const; bool operator>=(const Rational& rhs) const; const Rational& operator++(); // prefix const Rational operator++(int); // postfix const Rational& operator--(); // prefix const Rational operator--(int); // postfix friend ostream& operator<<(ostream&, const Rational&); friend istream& operator>>(istream&, Rational&); }; #endif