Last active
October 3, 2017 18:39
-
-
Save simplyniceweb/7c225b5ce578ef9069807a79dcc2f4d0 to your computer and use it in GitHub Desktop.
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
public void setRandomOptions() | |
{ | |
String[] answers = {}; | |
String[] options = {"PH", "USA", "NK", "SK"}; | |
Integer opt = 0; | |
while (2 > opt) { | |
String randomOption = options[new Random().nextInt(options.length)]; | |
// page eto working | |
/* | |
if (opt == 0) { | |
b2.setText(randomOption); | |
} else if (opt == 1) { | |
b3.setText(randomOption); | |
} | |
opt++; | |
*/ | |
// eto d working pero walang error | |
if (!indexExists(answers, opt)) { | |
answers[opt] = randomOption; | |
opt++; | |
} | |
} | |
b2.setText(answers[0]); | |
b3.setText(answers[1]); | |
} | |
public boolean indexExists(String[] array,int index){ | |
if(array!=null && index >= 0 && index < array.length) | |
return true; | |
else | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment