Adblock breaks this site

Highscores Lookup [Non-GUI]

Discussion in 'Programming General' started by SuF, Oct 15, 2008.

Thread Status:
Not open for further replies.
  1. SuF

    SuF Legend
    Pirate Retired Global Moderator

    Joined:
    Jan 21, 2007
    Posts:
    14,211
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary
    Highscores Lookup [Non-GUI]

    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
     
  2. Smd I Skill

    Smd I Skill Forum Addict
    Banned

    Joined:
    Aug 29, 2008
    Posts:
    367
    Referrals:
    0
    Sythe Gold:
    0
    Highscores Lookup [Non-GUI]

    pretty sweet, il give it a try.
     
  3. SuF

    SuF Legend
    Pirate Retired Global Moderator

    Joined:
    Jan 21, 2007
    Posts:
    14,211
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary
    Highscores Lookup [Non-GUI]

    Sure you will..... You don't even program do you?
     
  4. cp

    cp an cat
    Banned

    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0
    Highscores Lookup [Non-GUI]

    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:
     
  5. SuF

    SuF Legend
    Pirate Retired Global Moderator

    Joined:
    Jan 21, 2007
    Posts:
    14,211
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary
    Highscores Lookup [Non-GUI]

    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:
     
  6. somanayr

    somanayr Active Member

    Joined:
    Apr 25, 2010
    Posts:
    114
    Referrals:
    0
    Sythe Gold:
    0
    Highscores Lookup [Non-GUI]

    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!
     
  7. Jimmy

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25
    Highscores Lookup [Non-GUI]

    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.
     
  8. SuF

    SuF Legend
    Pirate Retired Global Moderator

    Joined:
    Jan 21, 2007
    Posts:
    14,211
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary
    Highscores Lookup [Non-GUI]

    You can see how old this is.... NEH to you Jimmy. NEH.
     
< LOcate | Compiling? >
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site