diff options
Completed ex2 from yesterdays oop practice
1 files changed, 17 insertions, 4 deletions
| -rw-r--r-- | Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h | 21 |
diff --git a/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h index f95e520..8d18289 100644 --- a/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h +++ b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h @@ -1,8 +1,17 @@ +#ifndef RATIONAL_HEADER +#define RATIONAL_HEADER + class Rational { int numerator; int denumerator; + bool gt(const Rational& other) const; + bool lt(const Rational& other) const; + + int gcd() const; + public: + Rational(); Rational(int numerator, int denumerator); int get_numerator() const; @@ -12,13 +21,17 @@ public: void set_denumerator(int denumerator); void canonize(); + void canonizeRec(); // Recursive canonize, that doesnt need gcd as a separate func - Rational operator+(const Rational& other); - Rational operator-(const Rational& other); - Rational operator*(const Rational& other); - Rational operator/(const Rational& other); + // Could easily be done with just normal functions, but this is more fun + Rational operator+(const Rational& other) const; + Rational operator-(const Rational& other) const; + Rational operator*(const Rational& other) const; + Rational operator/(const Rational& other) const; int numcmp(const Rational& arg) const; void print() const; }; + +#endif |
