-
Notifications
You must be signed in to change notification settings - Fork 1
/
state.cpp
55 lines (40 loc) · 1.01 KB
/
state.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
#include<iostream>
#include<fstream>
#include"state.h"
#include"fsm.h"
using namespace std;
state::state() {}
state::state(string iden) {
this->identifier=iden;
transitions=NULL;
}
state::state(string iden,state** transitions) {
this->identifier=iden;
this->transitions=transitions;
}
string state::name() {
return identifier;
}
void state::setTransitions(state** transitions) {
this->transitions=transitions;
}
state** state::giveTransitions() {
return transitions;
}
state state::input(int k) {
return *transitions[k];
}
bool state::isFinal() {
return finalState;
}
void state::setFinal(bool k) {
finalState=k;
}
void state::dump() {
cout << "Name of State : " << name() << "\n";
cout << "The transitions of the states are : ";
for(int i=0;i<no_of_transitions;i++) {
cout << "\n\t(for " << i+1 << "th input): " << transitions[i]->name();
}
cout << "\nFinal state? : " << ((finalState)?("Yes"):("No"));
}