-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterm.cpp
More file actions
37 lines (30 loc) · 663 Bytes
/
term.cpp
File metadata and controls
37 lines (30 loc) · 663 Bytes
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
#include"term.hpp"
#include<string>
#include<string.h>
using namespace std;
string Term :: toString(){
string term;
/*Checks for different things to properly format each term*/
if(coefficient ==0){
term = "0";
}
else if(exponent==0){
term = to_string(coefficient);
}
else if(exponent==1){
term = to_string(coefficient)+variable;
}
else{
term = to_string(coefficient)+variable+"^"+to_string(exponent);
}
return term;
}
int Term :: getCoefficient(){
return coefficient;
}
string Term :: getVariable(){
return variable;
}
int Term :: getExponent(){
return exponent;
}