From c105f7db9b10861dd0bdeedb3ed4d1ebe2054b87 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 29 Mar 2022 21:00:23 +0300 Subject: Added todays oop practice --- .../05-Practice-29.03.2022/ex2-Rational.h | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.h (limited to 'Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.h') diff --git a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.h b/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.h new file mode 100644 index 0000000..f95e520 --- /dev/null +++ b/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.h @@ -0,0 +1,24 @@ +class Rational { + int numerator; + int denumerator; + +public: + Rational(int numerator, int denumerator); + + int get_numerator() const; + void set_numerator(int numerator); + + int get_denumerator() const; + void set_denumerator(int denumerator); + + void canonize(); + + Rational operator+(const Rational& other); + Rational operator-(const Rational& other); + Rational operator*(const Rational& other); + Rational operator/(const Rational& other); + + int numcmp(const Rational& arg) const; + + void print() const; +}; -- cgit v1.3.1-26-gb76a