-
Notifications
You must be signed in to change notification settings - Fork 0
/
term.h
73 lines (57 loc) · 1.85 KB
/
term.h
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
70
71
72
73
#ifndef TERM_H
#define TERM_H
#include <iostream>
#include <fstream>
#include "fraction.h"
#include <cmath>
#include <sstream>
class term
{
public:
term(char v = 'x');
term(const fraction &c, const fraction& p = 0, char v = 'x');
term(std::string termString);
~term();
term(const term& other);
term& operator=(const term& other);
term& operator*=(const term& other);
term& operator/=(const term& other);
// term& operator+=(const term& other);
// term& operator-=(const term& other);
fraction getPower();
fraction getCoeff();
char getVar();
void setTerm(const fraction &c, const fraction p = 0, char v = 'x');
void setTerm(std::string termString); //TESTED
fraction evaluate(const fraction& other);
double evaluate(const double value);
fraction operator()(const fraction& other);
//y = x(3/4); where y and x are terms
friend
term operator*(const term &x, const term &y);
friend
term operator/(const term &x, const term &y);
friend
bool operator==(const term &x, const term &y);
friend
bool operator!=(const term &x, const term &y);
friend
bool operator>=(const term &x, const term &y);
friend
bool operator<=(const term &x, const term &y);
friend
bool operator>(const term &x, const term &y);
friend
bool operator<(const term &x, const term &y);
friend
bool operator%=(const term &x, const term &y);
friend
std::ostream& operator<<(std::ostream& out, const term& t);
friend
std::istream& operator>>(std::istream& in, term& t);
private:
fraction coeff, power;
char var;
void copy(const term &other);
};
#endif // TERM_H