I'm fairly new to C++ programming, so this is probably a rookie mistake. BUT. (why can't I hide the rest of my code... I want to show ALL of what I'm doing..)
So first off, the start to my code looks like this (headers and such, plus the first few lines of code)
#include <iostream>
#include <string>
using namespace std;
string command;
string playername;
char response;
string object;
int main()
{
do
{
cout << "What is your name? ";
cout << endl;
cin >> playername;
cout << endl;
cout << "Your name is " << playername << "? (Y/N)" << endl;
cout << endl;
cin >> response;
cout << endl;
cout << endl;
} while ((response != 'y')&&(response != 'Y'));
}
And then here's the problem bit:
do
{
cout << endl;
cout << "What will you do?";
cout << endl;
cin >> command >> object;
if ((command == "look")&&(object == "door"))
cout << "You look at the door. It appears to be but a simple wooden door
with a brass handle for opening and shutting. ";
else if ((command == "Open")&&(object == "door"))
cout << "You open the door and proceed to the next room";
} while ((command == "look")&&(command == "Look"));
}
My program will recognise when I put in "look" and "door" (as command and object) and responds with the appropriate "It's a door" line. BUT, when I put in "open" and "door" it just accepts it and ends the program, without displaying the text.
If there is ANY way I can rectify this I would be so very appreciative.
Thank you!
EDIT: for readability EDIT2: Changed last line to
}while ((command == "look")||(command == "Look"));
and I get: the bulwarky that is this code