• Log in or sign up for an account here: https://www.sythe.org/login

Highscores Lookup [Non-GUI]

Status
Not open for further replies.

SuF

Legend

Pirate
Retired Global Moderator
Joined
Jan 21, 2007
Sythe Gold
1,234
Messages
14,211
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
I made this to practice to make a program that takes two or three skills and finds the name of the person... It just shows levels, not XP or rank since it would be annoying to be rank and XP in a console read out. Lol.

For some reason all the closing brackets turned into **s... :(

Code:
package suf;

import java.net.*;
import java.io.*;
import java.util.*;

public class NameLookUp
{
	static Scanner s = new Scanner(System.in);
	public static String data = "";
	public static String[] skills =
	{ "Overall", "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", "Cooking", "WoodCutting", "Fletching", "Fishing", "Firemaking",
			"Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecrafting", "Hunter", "Construction", "Summoning" **;

	public static void main(String[] args)
	{
		parser(connect());
	**

	public static String connect()
	{

		while (true)
		{
			try
			{
				String player = getInput("Username:");
				URL site = new URL("http://hiscore.runescape.com/index_lite.ws?player=" + player);
				String html;
				BufferedReader in = new BufferedReader(new InputStreamReader(site.openStream()));
				while ((html = in.readLine()) != null)
				{
					if (data.equals(""))
					{
						data = html;
					**
					else
					{
						data = data + "," + html;
					**
				**
				return (data);
			**
			catch (MalformedURLException exc)
			{
				System.out.println("Error!");
			**
			catch (IOException exc)
			{
				System.out.println("That user does not have any high scores listed. Please pick another player.");
			**
		**
	**

	public static void parser(String input)
	{
		try
		{
			int skillnum = 0;
			StringTokenizer a = new StringTokenizer(input, ",");
			while (skillnum < 25)
			{
				a.nextToken();
				System.out.print(skills[skillnum] + ": ");
				String check = a.nextToken();
				if (check.equals("-1"))
				{
					System.out.println("Not Ranked");
				**
				else
				{
					System.out.println(check);
				**
				skillnum++;
				a.nextToken();
			**
		**
		catch (NoSuchElementException e)
		{
			System.out.println("Error!");
		**
	**

	public static String getInput(String output)
	{
		while (true)
		{
			try
			{
				System.out.print(output);
				return s.next();
			**
			catch (InputMismatchException e)
			{
				s.next();
			**
		**

	**
**

Thank you Sun website, Google, and Swans HTML downloading code which I used to figure out how to do all of this. :D
 
pretty sweet, il give it a try.
 
Code:
lol@lolx:~$ javac NameLookUp.java 
lol@lolx:~$ java NameLookUp 
Username:zezima
Overall: 2370
Attack: 99
Defence: 99
Strength: 99
Hitpoints: 99
Ranged: 99
Prayer: 99
Magic: 99
Cooking: 99
WoodCutting: 99
Fletching: 99
Fishing: 99
Firemaking: 99
Crafting: 99
Smithing: 99
Mining: 99
Herblore: 99
Agility: 99
Thieving: 99
Slayer: 99
Farming: 99
Runecrafting: 99
Hunter: 99
Construction: 99
Summoning: 93
Works just fine, nice job :)

I had to remove "package: suf;" to get it to work though D:
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
Hmmmm, I just throw it in there on all my shit... Works fine in eclipse.... The method to grab the page took the longest, well to make the returns work.. then debugging took awhile... only if you entered a username that had no scores... but it was pretty easy... i thought you would come and tell me it was horrible.. i waz scar3d!!! D:
 
I'll go ahead and bookmark this. Maybe come back to it later and try to understand it (plugging it in isn't enough!). I know this is an old thread, but do you mind adding some annotations to it so that it's easier for newbies like me to understand :) ?

Thanks!
 
I'll go ahead and bookmark this. Maybe come back to it later and try to understand it (plugging it in isn't enough!). I know this is an old thread, but do you mind adding some annotations to it so that it's easier for newbies like me to understand :) ?

Thanks!

I think you mean comments.

I'd highly suggest not using code from this, as it is quite disgusting (no offense to Jake) and will not give you good habits when writing your own in the future. I'ma go ahead and close this, but if you have any question on the basic IO and string manipulation done within this, then feel free to make your own thread here or pm somebody for help.
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
You can see how old this is.... NEH to you Jimmy. NEH.
 
Status
Not open for further replies.
Runescape Gamblingrunescape gambling
Back
Top