PDA

View Full Version : Problem with a few symbols in a Java calculator.



Toby1
08-06-2012, 04:57 PM
Hey, i'm trying to make a RuneScape Classic calculator in Simba,

this is the formula for the RuneScape Classic calculator!(in Java):


public static double combatFormulaRSC(int attack, int strength, int defence, int hitpoints, int prayer, int ranged, int magic)

{

double combatLevel = ((defence + hitpoints) * 0.25) + ((magic + prayer) * 0.125);



double warrior = (attack + strength) * 0.25;

double ranger = ranged * 0.375;



return combatLevel + (((ranged * 1.5) > (attack + strength)) ? ranger : warrior);

}


I understand a bit of the calculator but i'm having a problem with this:


return combatLevel + (((ranged * 1.5) > (attack + strength)) ? ranger : warrior);


what does the '?' represent in the formula? and the (ranger: warrior) thanks in advance.

Kasi
08-06-2012, 05:14 PM
it's a boolean thing, if its true it will call the first function/proc being ranger else it will call warrior

Kasi
08-06-2012, 05:17 PM
it's a boolean thing, if its true it will call the first function/proc being ranger else it will call warrior

Edit : in simba the code would be


If (combatLevel + (((ranged * 1.5) > (attack + strength))) then
Ranger;
else
Warrior;

Toby1
08-06-2012, 05:29 PM
Explained well, thanks. +rep