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.lookUp(Pair(currentState, 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, ok1, ok2, ok3, fa1, fa2, fa3
}
aState;
// represents different events for the lock
typedef enum EVENT
{
A, B, C, D, E, F
}
anEvent;
// functions
void actionTableFile(const string& fileName, Table, string>& actionTable);
void transTableFile(const string& fileName, Table, string>& transTable);
int mapping(const Pair key);
STATE stringtoSTATE(char input);
EVENT chartoEVENT(const 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(35, mapping);
Table, string> actionTable(35, mapping);
string transTablefile, actionTablefile;
cout << "Enter a file for the transition table please: ";
cin >> transTablefile;
transTableFile(transTablefile, transTable);
cout << "Enter a file for the action table please: ";
cin >> actionTablefile;
actionTableFile(actionTablefile, actionTable);
STATE currentState = nke;
char dealersChoice;
while (true)
{
cout << "Enter key using the following letters (A, B, C, D, E)...if you dare: ";
cin >> dealersChoice;
if (dealersChoice >='a' && dealersChoice <='e')
{
dealersChoice = toupper(dealersChoice);
}
if (dealersChoice <'A'|| dealersChoice >'E')
{
cout << "What you have entered is invalid! Silly human, please try again!" << endl;
continue;
}
EVENT currentEvent = chartoEVENT(dealersChoice);
STATE nextState = transTable.lookUp(Pair(currentState, currentEvent));
string action = actionTable.lookUp(Pair(currentState, 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? (Y/N): ";
cin >> mustGoOn;
if (tolower(mustGoOn)=='y')
{
currentState = nke;
continue;
}
else if (tolower(mustGoOn)=='n')
{
break;
}
}
}
return 0;
}
/******************************************************************************************
*
* Function Name: STATE stringtoSTATE(const 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 stringtoSTATE(const string& a)
{
if (a == "nke")
return nke;
else if (a =="ok1")
return ok1;
else if (a =="ok2")
return ok2;
else if (a =="ok3")
return ok3;
else if (a =="fa1")
return fa1;
else if (a =="fa2")
return fa2;
else if (a =="fa3")
return fa3;
else
{
return nke;
}
}
/******************************************************************************************
*
* Function Name: EVENT chartoEVENT(char 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 chartoEVENT(char 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 static_cast(0);
}
}
/******************************************************************************************
*
* Function Name: void actionTableFile

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!