Reputation: 29
I had made an integer named lifePoints then I set an If statement to CHANGE the integer's value from 100 to 90 how
int lifePoints = 100;
// not a full code but just giving an explanation
if (player == ("attackthem!"))
{
change integer value here. how?
}
I searched google and it came out changing String to integer.
Upvotes: 0
Views: 3519
Reputation: 359
If you want to set it to 90
, then:
lifePoints = 90;
If you want to substract 10
, then:
lifePoints -= 10;
OR: lifePoints = lifePoints - 10;
Upvotes: 0
Reputation: 1
int lifePoints = 100;
// not a full code but just giving an explanation
if (player == ("attackthem!"))
{
lifePoints = 90; //CHANGE the integer's value from 100 to 90
}
Upvotes: 0
Reputation: 4859
{
lifePoints -= 10;
}
which corresponds to
{
lifePoints = lifePoints - 10;
}
Upvotes: 2