Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / 06-Practice-29.03.2022 / ex2 / Rational.h
diff options
context:
space:
mode:
Commitef6d8e6de6061015e7dd41e2f74b733515b4a2e2 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-03-30 15:17:07 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-03-30 15:17:07 +0300
Files285ccedc5b4296a7022f4de131bbb5ab44bd99bc /Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h
uni-projects-ef6d8e6de6061015e7dd41e2f74b733515b4a2e2.tar
uni-projects-ef6d8e6de6061015e7dd41e2f74b733515b4a2e2.tar.gz
uni-projects-ef6d8e6de6061015e7dd41e2f74b733515b4a2e2.zip
Parent793100813b3c50a1f304904440366a7137ae0992 (diff)
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.h21
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