if (wORa == 1)
{
cout << "\n\nLooking for some high-quality weaponry, eh? Well, here's what I've got!\n\n";
cout << "1) " << blade << "\nDamage: " << bladestat << "\nPrice: " << bladeprice << "\n\n";
cout << "2) " << broadsword << "\nDamage: " << broadswordstat << "\nPrice: " << broadswordprice << "\n\n";
cout << "3) " << longsword << "\nDamage: " << longswordstat << "\nPrice: " << longswordprice << "\n\n";
cout << "4) " << enchantedclaymore << "\nDamage: " << enchantedclaymorestat << "\nPrice: " << enchantedclaymoreprice << "\n\n";
cout << "You have " << playergp << " gold.\n\n";
cout << "Either type the number of your desired purchase, or type 5 to go back to the\n";
cout << "Game menu. ";
cin >> weppurchase;
if (weppurchase == 1)
{
if (playergp >= bladeprice)
{
cout << "\n\nYou have purchased a Blade. Thanks, and have a nice day!";
playergp = playergp - bladeprice;
playerwep = bladestat;
strcpy (playerwepname, blade);
}
else if (playergp < bladeprice)
{
cout << "\n\nYou do not have enough gold to purchase that weapon.";
}
else if (weppurchase == 2)
{
if (playergp >= broadswordprice)
{
cout << "\n\nYou have purchased a Broadsword. Thanks, and have a nice day!";
playergp = playergp - broadswordprice;
playerwep = broadswordstat;
strcpy (playerwepname, broadsword);
}
else if (playergp < broadswordprice)
{
cout << "\n\nYou do not have enough gold to purchase that weapon.";
}
}
}
else if (weppurchase == 1337)
{
cout << "In a magestic sparkling of light, 500 gold mysteriously appears in your wallet!";
playergp = playergp + 500;
}
}
What's wrong with this code?
You have put a closing brace in the wrong place, so that your else if becomes part of
if (playergp >= bladeprice)
Look closely at your code, match up the braces with their counterparts.
if (playergp >= bladeprice)
Look closely at your code, match up the braces with their counterparts.
The bracket is in the incorrect place.
check the brakets before and after the section
check the brakets before and after the section
<--------------------------else if (weppurchase == 2) |{ |} |} >------------->-----------/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement