Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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, ok ok ok fa fa fa;
typedef enum EVENT A B C D E F anEvent;
int mappingconst Pair& p
return pfirst psecond;
int main
std::ifstream combinationFilecorrectcombination.txt;
if combinationFile.isopen
std::cerr "Error: Could not open combination file." std::endl;
return ;
std::string correctCombination;
std::getlinecombinationFile correctCombination;
combinationFile.close;
Table, STATE transitiontable mapping;
Table, std::string actiontable mapping;
transitiontable.insertmakePairmakePairnke A fa;
actiontable.insertmakePairmakePairnke A "alarm";
std::string enteredCombination;
std::cout "Enter the combination: ;
std::getlinestd::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 ;
Pair key makePaircurrentState event;
int index mappingkey;
currentState transitiontable.lookUpkey;
std::string action actiontable.lookUpkey;
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 ;
Problem show in the picture please solve for me
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started