blob: 05794b5d622d1387f626dd1fa9567a089429bfc5 (
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
38
39
40
41
42
43
44
45
46
47
|
#include "ex2-Rational.h"
Rational::Rational(int numerator, int denumerator) {
set_numerator(numerator);
set_denumerator(denumerator);
}
int Rational::get_numerator() const {
return numerator;
}
void Rational::set_numerator(int numerator) {
this->numerator = numerator;
}
int Rational::get_denumerator() const {
return denumerator;
}
void Rational::set_denumerator(int denumerator) {
this->denumerator = denumerator;
}
void canonize() {
}
Rational Rational::operator+(const Rational& other) {
return Rational(numerator * other.denumerator + other.numerator * denumerator, denumerator * other.denumerator);
}
//x a = x*b + y*a
//y b y*b
Rational Rational::operator-(const Rational& other) {
return Rational(numerator * other.denumerator - other.numerator * denumerator, denumerator * other.denumerator);
}
Rational Rational::operator*(const Rational& other) {
return Rational(numerator * other.numerator, denumerator * other.denumerator);
}
Rational Rational::operator/(const Rational& other) {
return Rational(numerator / other.numerator, denumerator / other.denumerator);
}
int Rational::numcmp(const Rational& arg) const {
}
|