#include #include using namespace std; int main() { // Is the room locked bool locked=true; // Does the player have the key. bool key=false; // Player's command string command; do { cout << "Enter in a command: "; getline(cin,command); // If the player looks at the room. if(command=="look") { if(key==false) cout << "The door is locked and there is a key on the table." << endl; else cout << "The door is locked." << endl; } if(command=="get key") { if(key==false) { cout << "You now have the key." << endl; key=true; } else cout << "You already have the key." << endl; } if(command=="open door") { if(key==false) cout << "Key is needed to open door." << endl; else { cout << "Door is now open." << endl; cout << "You win!" << endl; locked=false; } } }while(locked && command!="quit"); return 0; }