I think I need to cast this code. I need to return an int but I have to multiply by percents and dont want them to be cut off.
Should I cast it like this brains = (double)brains - (this.getBrains() * 0.01);
Also should I cast the return statement at the end? I'm weak at casting and i've been trying to find examples to help but they're not helping.
if(attacker >= attackee)
{
switch (weapon)
{
case 't':
brains = brains + (other.getBrains() * 0.01);
attack = other.getBrains() * -0.01;
other.addBrains(attack);
break;
case 's':
brains = brains + (other.getBrains() * 0.05);
attack = other.getBrains() * -0.05;
other.addBrains(attack);
break;
case 'c':
brains = brains + (other.getBrains() * 0.10);
attack = other.getBrains() * -0.10;
other.addBrains(attack);
break;
case 'k':
brains = brains + (other.getBrains() * 0.20);
attack = other.getBrains() * -0.20;
other.addBrains(attack);
break;
}
}
else
{
switch (weapon)
{
case 't':
brains = brains - (this.getBrains() * 0.01);
attack = this.getBrains() * 0.01;
other.addBrains(attack);
break;
case 's':
brains = brains - (this.getBrains() * 0.01);
attack = this.getBrains() * 0.01;
other.addBrains(attack);
break;
case 'c':
brains = brains - (this.getBrains() * 0.01);
attack = this.getBrains() * 0.01;
other.addBrains(attack);
break;
case 'k':
brains = brains - (this.getBrains() * 0.01);
attack = this.getBrains() * 0.01;
other.addBrains(attack);
break;
}
}
return attack;
}