SRL Archive - Java Help and Tutorials

Problem with a few symbols in a Java calculator.


Toby1

2012-08-06 12:57:47

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

2012-08-06 13:14:30

it's a boolean thing, if its true it will call the first function/proc being ranger else it will call warrior

Kasi

2012-08-06 13:17:21

From: pur3b100d
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

2012-08-06 13:29:27

Explained well, thanks. +rep