Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / 06-Practice-29.03.2022 / ex2 / Rational.h
blob: 8d1828914f9a8f76aa8aa418e262972ee0d98f12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#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;
	void set_numerator(int numerator);

	int get_denumerator() const;
	void set_denumerator(int denumerator);

	void canonize();
	void canonizeRec(); // Recursive canonize, that doesnt need gcd as a separate func

	// 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