I was trying to do something using a varible such as experience or gold, and i was wondering if there was a way to set a limit to a greater than or less than statement like
1 2 3 4 5 6 7 8 9 10
if (gold//through statement that set the limit for gold)
{
//make an option to buy something
}
else
{
cout << "You don't have enough money to buy this. \n";
//I know when working with a store no limits is good but i want to be able to set a max
return 1;
}
the problem with greater than or less than is that when using a loop, the test will always be true for the lack of the limit thanks for your time
I don't know if I understand. Is this what you want?
1 2 3 4 5 6 7 8 9 10 11
if (gold >= cost)
{
// do something
gold -= cost;
}
else
{
cout << "You don't have enough money to buy this. \n";
//I know when working with a store no limits is good but i want to be able to set a max
return 1;
}
while gold = 1-99 // do something
// but i dont want it to be subtraction, i want it to only work while the varible is between 2 numbers
or mabye heres a better example
1 2 3 4 5 6 7 8 9 10 11
level=0
experience=0
if (experience 1-99//but not subtraction, while the number is between)
{
level=1
}
if (experience 100-199//again not subtraction)
{
level=2//and so on
}
that is easier, but i dont want it to continue to be level=0
because as you gain something like experience dont you want the varible to be 2 things at once, else if it causes the new statement to overwrite the old, dont you have to rerun it each time you gain experience