Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


My java code filter_list
Author
Message
My java code #1
I started learning java here some code I wrote.

Code:
1| String[][] usernames= {
2|           {"Blunt", "Eclipse", " Oni"},
3|          {"Tarew", " Master", " Lux"}
4|       };
5|                  
6|       String[][] amount= {
7|           {"86", "59", "46"}
8|       };
9|        
10|       String and = " and ";
11|      String has = " has ";
12|            
13|      System.out.println("Richest users are " +usernames[0][1] +and + usernames[1][1]);    
14|      System.out.println(usernames[0][1] +has + amount[0][0]);    
15|       System.out.println(usernames[1][1] +has + amount[0][1]);  
16|      };

Code:
Richest users are Eclipse and  Master
Eclipse has 86
Master has 59

[Image: 3wiRj+]
(This post was last modified: 02-02-2015, 11:16 AM by Master.)
[Image: master645.png]

Life before death, strength before weakness, journey before destination.” ― The Way of Kings by Brandon Sanderson

Reply

RE: My java code #2
Cool, I'm on that list. Just wait until I'm top.
[Image: 8536321abf.jpg]Me and Lux are the realest users here.
[STAFF DETERMINED SIGNATURE AS LEWD]
JDM>USDM

Reply

RE: My java code #3
(02-02-2015, 01:28 PM)Johnny Wrote: Cool, I'm on that list. Just wait until I'm top.

Not on my watch fgt.

Reply

RE: My java code #4
(02-02-2015, 01:28 PM)Johnny Wrote: Cool, I'm on that list. Just wait until I'm top.

Agree with Alex, no Europol agent will be the richest user as long as I fucking live.

Good job though @Master

Reply

RE: My java code #5
You should connect to the site and read the richest user instead of typing it into the code.

Reply

RE: My java code #6
(02-02-2015, 08:59 PM)Eclipse Wrote: You should connect to the site and read the richest user instead of typing it into the code.

Great idea how would you do it.
[Image: master645.png]

Life before death, strength before weakness, journey before destination.” ― The Way of Kings by Brandon Sanderson

Reply

RE: My java code #7
Read page html. Find relevant part. Get data. Print in proper format.

Reply

RE: My java code #8
I wouldn't do it in Java, afaik sockets are a PITA. But if you know how to use them, just match a regex

start looking when this is matched:
Code:
</table><br/>
<table border="0" cellspacing="0" cellpadding="5" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>Richest Users</strong></td>
</tr>
<tr>
<td class="tcat" width="50%"><strong>User</strong></td>
<td class="tcat" width="50%" align="center"><strong>Amount</strong></td>
</tr>

then, follow this format:
Code:
<tr>
<td class="trow1" width="50%"><a href="{link here}">{username}</a></td>
<td class="trow1" width="50%" align="center">{amount}</td>
</tr>

Reply

RE: My java code #9
(02-03-2015, 12:45 AM)phyrrus9 Wrote: I wouldn't do it in Java, afaik sockets are a PITA. But if you know how to use them, just match a regex

start looking when this is matched:
Code:
</table><br/>
<table border="0" cellspacing="0" cellpadding="5" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>Richest Users</strong></td>
</tr>
<tr>
<td class="tcat" width="50%"><strong>User</strong></td>
<td class="tcat" width="50%" align="center"><strong>Amount</strong></td>
</tr>

then, follow this format:
Code:
<tr>
<td class="trow1" width="50%"><a href="{link here}">{username}</a></td>
<td class="trow1" width="50%" align="center">{amount}</td>
</tr>
From personal experience and what others have said, regex tends to be the overly complicated way of parsing html, especially when you need to find lots of specific elements and such

But regex could be used for this kind of stuff, just wanted to throw that it there that you probably shouldn't use overly complicated regular expressions for complex html parsing

Reply

RE: My java code #10
What was your reasoning behind creating the two strings "and" & "has" instead of just printing everything out like this?

System.out.println("Richest users are " +usernames[0][1] + "and" + usernames[1][1]);
System.out.println(usernames[0][1] + "has" + amount[0][0]);
System.out.println(usernames[1][1] + "has" + amount[0][1]);

Reply







Users browsing this thread: 1 Guest(s)