-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariable.cpp
More file actions
45 lines (36 loc) · 697 Bytes
/
Copy pathVariable.cpp
File metadata and controls
45 lines (36 loc) · 697 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
38
39
40
41
42
43
44
45
#include <stdexcept>
#include <iostream>
#include "Variable.h"
using namespace std;
Variable::Variable(const double& power, string name)
{
if (name.size() == 0) {
throw invalid_argument("You trying to create variable with no name");
}
this->power = power;
this->name = name;
this->createLabel();
}
double Variable::getPower() const
{
return this->power;
}
string Variable::getName() const
{
return this->name;
}
string Variable::getLabel() const
{
return this->label;
}
void Variable::createLabel()
{
string label = "";
label += this->name;
label += to_string(this->power);
this->label = label;
}
void Variable::setPower(const double& newPower)
{
this->power = newPower;
}