Skip to content

Instantly share code, notes, and snippets.

@paulerickson
Created April 26, 2009 04:36
Show Gist options
  • Save paulerickson/101883 to your computer and use it in GitHub Desktop.
Save paulerickson/101883 to your computer and use it in GitHub Desktop.
//in ThePanel.java...
int r = 0, c = 0;
do{
r = (int)(Math.random() * 5); //I wouldn't expect this to cause problems,
c = (int)(Math.random() * 5); //but Math.random() is a double, and 5 is an int
} //it would be better form to use 5.0, which is a double
while (r + c >= 5);
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment