This question already has an answer here:
- New Random Number Not Generating 1 answer
please i have two TextView in android studio activity, and those Text has a Random number i need to multiple and get result, but while get random number, the duplicate of same number occur, how i can prevent that? this my code:
if (Integer.parseInt(num1.text.toString()) * Integer.parseInt(num2.text.toString())
== Integer.parseInt(result.text.toString())) {
Toast.makeText(applicationContext, "right", Toast.LENGTH_LONG).show()
and my function use to generate random number is :
private fun randomNumber():Int{
val rand = Random();
return rand.nextInt(10) +1
}
Aucun commentaire:
Enregistrer un commentaire