Question: overloded problem please fix for me : #include #include #include table.h #include using namespace std; / / Define the states and events ( already

overloded problem please fix for me :
#include
#include
#include "table.h"
#include
using namespace std;
// Define the states and events (already defined in your problem statement)
enum STATE { nke, ok1, ok2, ok3, fa1, fa2, fa3};
typedef enum EVENT { A, B, C, D, E, F } anEvent;
int mapping(const Pair& p)
{
return (p.first *6)+ p.second;
}
int main(){
std::ifstream combinationFile("correct_combination.txt");
if (!combinationFile.is_open())
{
std::cerr "Error: Could not open combination file." std::endl;
return 1;
}
std::string correctCombination;
std::getline(combinationFile, correctCombination);
combinationFile.close();
Table, STATE> transition_table(21, mapping);
Table, std::string > action_table(21, mapping);
transition_table.insert(makePair(makePair(nke, A), fa1));
action_table.insert(makePair(makePair(nke, A), "alarm"));
std::string enteredCombination;
std::cout "Enter the combination: ";
std::getline(std::cin, enteredCombination);
STATE currentState = nke;
bool unlocked = false;
for (char ch : enteredCombination){
anEvent event;
switch (ch)
{
case 'A': event = A; break;
case 'B': event = B; break;
case 'C': event = C; break;
case 'D': event = D; break;
case 'E': event = E; break;
case 'F': event = F; break;
default:
std::cerr "Invalid character entered." std::endl;
return 1;
}
Pair key = makePair(currentState, event);
int index = mapping(key);
currentState = transition_table.lookUp(key);
std::string action = action_table.lookUp(key);
if (action == "unlock")
{
unlocked = true;
break;
}
else if (action == "alarm")
{
std::cout "Alarm! Incorrect combination." std::endl;
break;
}
}
if (unlocked)
{
std::cout "Lock unlocked!" std::endl;
}
else if (!unlocked && enteredCombination.size()== correctCombination.size())
{
std::cout "Incorrect combination." std::endl;
}
return 0;
}
Problem show in the picture please solve for me
 overloded problem please fix for me : #include #include #include "table.h"

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!