From ef6d8e6de6061015e7dd41e2f74b733515b4a2e2 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 30 Mar 2022 15:17:07 +0300 Subject: Completed ex2 from yesterdays oop practice --- .../06-Practice-29.03.2022/ex2/Rational.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h') 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 -- cgit v1.3.1-26-gb76a