-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rational.hpp
69 lines (67 loc) · 2.2 KB
/
Rational.hpp
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef RATIONAL_HPP
# define RATIONAL_HPP
#include "utils.hpp"
#include "Symbol.hpp"
#include "Number.hpp"
class Complex;
class Matrix;
class Rational : public Symbol
{
public:
class ModuloByNonIntException : public exception
{
virtual const char* what() const throw();
};
class ModuloByZeroException : public exception
{
virtual const char* what() const throw();
};
class DivisionByZeroException : public exception
{
virtual const char* what() const throw();
};
class NotANumberException : public exception
{
virtual const char* what() const throw();
};
class NumberTooLongException : public exception
{
virtual const char* what() const throw();
};
Rational();
Rational(string data) throw (NumberTooLongException, NotANumberException);
Rational(Rational const &src);
Rational(Number const &numerator, Number const &denominator);
~Rational();
bool operator==(Rational const &rhs);
bool operator!=(Rational const &rhs);
bool operator>(Rational const &rhs);
bool operator>=(Rational const &rhs);
bool operator<(Rational const &rhs);
bool operator<=(Rational const &rhs);
bool isNumber() const;
Rational& operator=(Rational const &rhs);
Rational operator+(Rational const &rhs);
Rational operator-(Rational const &rhs);
Rational operator*(Rational const &rhs);
Rational operator/(Rational const &rhs) throw(DivisionByZeroException);
Rational operator%(Rational const &rhs) throw(ModuloByNonIntException, ModuloByZeroException);
Rational operator^(Number power);
Rational round() const;
Complex operator+(Complex const &rhs);
Complex operator-(Complex const &rhs);
Complex operator*(Complex const &rhs);
Complex operator/(Complex const &rhs);
Matrix operator*(Matrix const &rhs);
Complex getRoot() const;
Number getNumerator() const;
Number getDenominator() const;
Rational abs() const;
pair <wstring,int> getApproximation() const;
string approximation() const;
private:
Number _numerator;
Number _denominator;
};
ostream& operator<<(ostream &o, Rational const &rhs);
#endif