forked from shalevf6/AP-scriptRunner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringVariable.cpp
More file actions
76 lines (64 loc) · 1.45 KB
/
StringVariable.cpp
File metadata and controls
76 lines (64 loc) · 1.45 KB
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
74
75
76
#include <iostream>
#include "StringVariable.h"
using namespace std;
/*
* constructor of new string variable.
* value - the given value of the variable.
* name - the given name of the variable.
* type - the type of the variable
*/
StringVariable::StringVariable(string value, string name, string type):m_value(value) , Variable(name,type) {}
/*
*destructor of the variable.
*/
StringVariable::~StringVariable() {}
/*
* sets new value of the current variable.
* value - the new value of the variable.
*/
void StringVariable::setValue(string value)
{
m_value = value;
}
/*
* return the value of the variable.
*/
string StringVariable::getValue() const
{
return m_value;
}
/*
* copying a given bool variable into te current variable.
* b1 - the given variable.
*/
StringVariable& StringVariable::operator=(const StringVariable& b1)
{
string a = b1.getValue();
setValue(a);
return *this;
}
/*
* returns true or false is the value of the current variable is identical to the value of
* the given variable.
* b1 - the given variable
*/
bool StringVariable::operator==(const StringVariable& b1)const
{
string a = b1.getValue();
string b = getValue();
return a == b;
}
/*
* A private function to print the variable.
*/
ostream & StringVariable::Show(ostream & out)const
{
cout<<m_value;
}
/*
* printing a given variable with the right format
*/
ostream & operator<<(ostream& out,const StringVariable & s)
{
s.Show(out);
}