-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quadruple.cpp
57 lines (48 loc) · 1009 Bytes
/
Quadruple.cpp
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
/*
* File: Quadruple.cpp
* Author: claire
*
* Created on November 19, 2013, 8:50 PM
*/
#include "Quadruple.h"
Quadruple::Quadruple() : operation(""), arg1(""), arg2(""), result("") {
}
Quadruple::Quadruple(const Quadruple& orig) : operation(orig.operation),
arg1(orig.arg1), arg2(orig.arg2), result(orig.result)
{
}
Quadruple::~Quadruple() {
}
//creates a quadruple with the given arguments
Quadruple::Quadruple(string oper, string arg1, string arg2, string result){
this->operation = oper;
this->arg1 = arg1;
this->arg2=arg2;
this->result = result;
}
//returns the quadruple in the proper string format for the interpreter
string Quadruple::getQuadrupleTuple() {
string tuple = "(" + operation + ",";
if(arg1 != "") {
tuple += arg1;
}
else {
tuple += "-";
}
tuple += ",";
if(arg2 != "") {
tuple += arg2;
}
else {
tuple += "-";
}
tuple += ",";
if(result != "") {
tuple += result;
}
else {
tuple += "-";
}
tuple += ")";
return tuple;
}