Highscores Lookup [Non-GUI]

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

Thread Status:
Not open for further replies.
Highscores Lookup [Non-GUI]
  1. Unread #1 - Oct 15, 2008 at 7:06 PM
  2. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    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

    SuF Legend
    Pirate Retired Global Moderator

    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
     
  3. Unread #2 - Oct 15, 2008 at 7:52 PM
  4. Smd I Skill
    Joined:
    Aug 29, 2008
    Posts:
    367
    Referrals:
    0
    Sythe Gold:
    0

    Smd I Skill Forum Addict
    Banned

    Highscores Lookup [Non-GUI]

    pretty sweet, il give it a try.
     
  5. Unread #3 - Oct 15, 2008 at 8:20 PM
  6. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    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

    SuF Legend
    Pirate Retired Global Moderator

    Highscores Lookup [Non-GUI]

    Sure you will..... You don't even program do you?
     
  7. Unread #4 - Oct 15, 2008 at 8:29 PM
  8. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    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:
     
  9. Unread #5 - Oct 15, 2008 at 8:38 PM
  10. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    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

    SuF Legend
    Pirate Retired Global Moderator

    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:
     
  11. Unread #6 - May 6, 2010 at 10:46 PM
  12. somanayr
    Joined:
    Apr 25, 2010
    Posts:
    114
    Referrals:
    0
    Sythe Gold:
    0

    somanayr Active Member

    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!
     
  13. Unread #7 - May 6, 2010 at 11:43 PM
  14. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    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.
     
  15. Unread #8 - May 7, 2010 at 1:17 PM
  16. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    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

    SuF Legend
    Pirate Retired Global Moderator

    Highscores Lookup [Non-GUI]

    You can see how old this is.... NEH to you Jimmy. NEH.
     
< LOcate | Compiling? >

Users viewing this thread
1 guest
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site