-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transition.cpp
61 lines (57 loc) · 1.24 KB
/
Transition.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
58
59
60
61
#include "Transition.h"
#include <string>
#include <iostream>
using namespace std;
// constractor
Transition::Transition(string startState, char token, string endState)
{
// setting the data
StartState = startState;
Token = token;
EndState = endState;
}
// destructor
Transition::~Transition()
{
// clearing all the variables after finishing with each one of them
// memory managment
StartState.clear();
Token = (char)0;
EndState.clear();
}
// the get functions
string Transition::getStartState() const
{
return StartState;
}
string Transition::getEndState() const
{
return EndState;
}
char Transition::getToken() const
{
return Token;
}
string Transition::toString()
{
return "({" + StartState + "}, {" + Token + "}) => {" + EndState + "}\n";
}
// the set functions
void Transition::setStartState(string newStartState)
{
StartState = newStartState;
}
void Transition::setEndState(string newEndState)
{
EndState = newEndState;
}
void Transition::setToken(char newToken)
{
Token = newToken;
}
// the overloading cout operator
ostream & operator<<(ostream & strm, const Transition & obj)
{
strm << "({" + obj.StartState + "}, {" + obj.Token + "}) => {" + obj.EndState + "}";
return strm;
}