Experience { public static int getLevelForXp(int xp) { if (xp < 0) { throw new IllegalArgumentException("XP (" + xp + ") must not be negative"); } int low = 0; int high = XP_FOR_LEVEL.length - 1; while (low <= high) { int mid = low + (high - low) / 2; int xpForLevel = XP_FOR_LEVEL[mid]; if (xp < xpForLevel) { high = mid - 1; } else if (xp > xpForLevel) { low = mid + 1; } else { return mid + 1; } } return high + 1; }  static int getXpForLevel(int level); static int getLevelForXp(int xp); static double getCombatLevelPrecise(int attackLevel, int strengthLevel,
		int defenceLevel, int hitpointsLevel, int magicLevel,
		int rangeLevel, int prayerLevel); static int getCombatLevel(int attackLevel, int strengthLevel,
		int defenceLevel, int hitpointsLevel, int magicLevel,
		int rangeLevel, int prayerLevel); static int getNextCombatLevelMelee(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel,
		int magicLevel, int rangeLevel, int prayerLevel); static int getNextCombatLevelHpDef(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel,
		int magicLevel, int rangeLevel, int prayerLevel); static int getNextCombatLevelMagic(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel,
		int magicLevel, int rangeLevel, int prayerLevel); static int getNextCombatLevelRange(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel,
		int magicLevel, int rangeLevel, int prayerLevel); static int getNextCombatLevelPrayer(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel,
		int magicLevel, int rangeLevel, int prayerLevel); static final int MAX_REAL_LEVEL; static final int MAX_VIRT_LEVEL; static final int MAX_SKILL_XP; static final int MAX_COMBAT_LEVEL; }
@Test public void testGetLevelForXp() { int level = Experience.getLevelForXp(XP_FOR_99); assertEquals(99, level); level = Experience.getLevelForXp(XP_FOR_99 - 1); assertEquals(98, level); level = Experience.getLevelForXp(XP_FOR_126); assertEquals(126, level); level = Experience.getLevelForXp(XP_FOR_126 - 1); assertEquals(125, level); level = Experience.getLevelForXp(Integer.MAX_VALUE); assertEquals(126, level); level = Experience.getLevelForXp(0); assertEquals(1, level); }
@Test(expected = IllegalArgumentException.class) public void testGetLevelForNegativeXP() { Experience.getLevelForXp(-1); }