Question: i need help fixing my code please, this specific line is giving an error message: STATE nextState = transTable.lookUp ( Pair ( currentState , currentEvent
i need help fixing my code please, this specific line is giving an error message: STATE nextState transTable.lookUpPaircurrentState currentEvent; but here is the entire code make changes as you see fit C: #include
#include
#include
#include
#include
#include "table.h
using namespace std;
defines different states of the finite state machine
typedef enum STATE
nke, ok ok ok fa fa fa
aState;
represents different events for the lock
typedef enum EVENT
A B C D E F
anEvent;
functions
void actionTableFileconst string& fileName, Table, string& actionTable;
void transTableFileconst string& fileName, Table, string& transTable;
int mappingconst Pair key;
STATE stringtoSTATEchar input;
EVENT chartoEVENTconst string& a;
Function Name: main
Purpose: The main function of the program. It initalizes the trans and action tables,
reads input files to populate these tables, then runs the finite state machine
based on user input.
Input Parameters: none
Output parameters: none
Return Value: Returns an integer value indicating the success or failure of the program.
int main
Table, string transTable mapping;
Table, string actionTable mapping;
string transTablefile, actionTablefile;
cout "Enter a file for the transition table please: ;
cin transTablefile;
transTableFiletransTablefile transTable;
cout "Enter a file for the action table please: ;
cin actionTablefile;
actionTableFileactionTablefile actionTable;
STATE currentState nke;
char dealersChoice;
while true
cout "Enter key using the following letters A B C D Eif you dare: ;
cin dealersChoice;
if dealersChoice a && dealersChoice e
dealersChoice toupperdealersChoice;
if dealersChoice A dealersChoice E
cout "What you have entered is invalid! Silly human, please try again!" endl;
continue;
EVENT currentEvent chartoEVENTdealersChoice;
STATE nextState transTable.lookUpPaircurrentState currentEvent;
string action actionTable.lookUpPaircurrentState currentEvent;
if action.empty
cout "Action: action endl;
cout
Current State: currentState
Next State: currentState endl;
currentState nextState;
if action "unlock" action "alarm"
char mustGoOn;
cout Do you want to try again? YN: ;
cin mustGoOn;
if tolowermustGoOny
currentState nke;
continue;
else if tolowermustGoOnn
break;
return ;
Function Name: STATE stringtoSTATEconst string& a
Purpose: Concerts a string of a state representation to its corresponding enum value.
Input Parameters: a String representation of the state
Output parameters: none
Return Value: Enum value corresponding to the input string represention of the state.
STATE stringtoSTATEconst string& a
if a "nke"
return nke;
else if a ok
return ok;
else if a ok
return ok;
else if a ok
return ok;
else if a fa
return fa;
else if a fa
return fa;
else if a fa
return fa;
else
return nke;
Function Name: EVENT chartoEVENTchar input
Purpose: Converts a character representation of an event to its corresponding enum value.
Input Parameters: input Character represention of event.
Output parameters: none
Return Value: Enum value corresponding to the input character respresentation of the event.
EVENT chartoEVENTchar input
switch input
case A:
return A;
case B:
return B;
case C:
return C;
case D:
return D;
case E:
return E;
default:
return staticcast;
Function Name: void actionTableFile
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
