<iostream> is included twice, the second one will have no effect.
@
xismn:
i don't know if you read the code carefully, this is exactly what
OP need.
@
OP:
you can't make any program by hard coding it like this one.
if you want to make a game, try using OOP, it's a lot better.
if you don't know how to use OOP, and still insist to try this game, i suggest you try the following:
- the game body should be in a loop.
- the assignment and binary operators are there to change variables, so use them:
instead of:
cout<< "You now have " << gold-100 << " Gold.\n";
use this:
1 2
|
gold -= 100;
cout<<"you now have "<<gold<<" Gold."<<std::endl;
| |
do the same for all similar cases.
- don't let the user know you use number to represent commands, you request a command from the user as a string, and transforming it to a unique number is your choice, you can still use
string::compare().
- your code shall not contain the conversation of the game, you should store the conversation in another place (like a two dimensional array), and the code must be able to work on any conversation provided.