-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVar.cpp
50 lines (43 loc) · 938 Bytes
/
Var.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
//
// Created by matan on 12/20/19.
//
#include "Var.h"
#include "helpFromEx1.h"
#include "GeneralResources.h"
//changing the val of a var:
void Var::changeVal(double val1) {
Var::val = val1;
}
//constructor:
Var::Var(string name1, bool simOrVal1, bool inOrOut1, string valOrPath1) {
Var::simOrVal = simOrVal1;
Var::name = name1;
//checking the type of var we have:
if(simOrVal)
{
Var::path = removeEndings(valOrPath1);
Var::inOrOut = inOrOut1;
Var::val = 0;
}
else
{
Var::path = "";
Interpreter* i = new Interpreter();
//calculating it's curr value:
i->setVariables(tableToString());
Var::val = (i->interpret(valOrPath1))->calculate();
delete i;
}
}
//removes all the ":
string Var::removeEndings(string basic_string) {
stringstream stringBuilder;
for(char c : basic_string)
{
if(c != '\"')
{
stringBuilder<<c;
}
}
return stringBuilder.str();
}