Created
June 4, 2014 20:42
-
-
Save euank/00761f6b5077a2263589 to your computer and use it in GitHub Desktop.
Yes it's a joke. Random number generator in java.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.net.*; | |
| import java.io.*; | |
| import java.util.*; | |
| class RandNum { | |
| public static void main(String[] args) { | |
| for(int i=0;i<100;i++) { | |
| System.out.println("Your random number is: " + GetRandomNumber(1,2)); | |
| } | |
| } | |
| public static int GetRandomNumber(int min, int max) { | |
| try { | |
| String url = "http://www.random.org/integers/?num=1&min=" + min + "&max="+max+"&col=1&base=10&format=plain&rnd=new"; | |
| BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream())); | |
| String randNumber = in.readLine(); | |
| in.close(); | |
| return Integer.parseInt(randNumber); | |
| } | |
| catch(Exception e) { //Pokemon | |
| } | |
| return new Random().nextInt(max) + min; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment