mirror of
https://github.com/Skysamara/android-kotlin-fundamentals-apps.git
synced 2025-12-06 06:16:03 +00:00
Merge pull request #21 from google-developer-training/developer
Fix: Changing the function call to generate random numbers
This commit is contained in:
commit
6b8922d07f
@ -47,7 +47,7 @@ class MainActivity : AppCompatActivity() {
|
||||
* Click listener for the Roll button.
|
||||
*/
|
||||
private fun rollDice() {
|
||||
val randomInt = Random().nextInt(6) + 1
|
||||
val randomInt= (1..6).random()
|
||||
|
||||
val resultText: TextView = findViewById(R.id.result_text)
|
||||
resultText.text = randomInt.toString()
|
||||
|
||||
@ -46,7 +46,7 @@ class MainActivity : AppCompatActivity() {
|
||||
private fun rollDice() {
|
||||
// Toast.makeText(this, "button clicked",
|
||||
// Toast.LENGTH_SHORT).show()
|
||||
val randomInt = Random().nextInt(6) + 1
|
||||
val randomInt = (1..6).random()
|
||||
|
||||
val resultText: TextView = findViewById(R.id.result_text)
|
||||
resultText.text = randomInt.toString()
|
||||
|
||||
@ -55,7 +55,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun getRandomDiceImage() : Int {
|
||||
val randomInt = Random().nextInt(6) + 1
|
||||
val randomInt = (1..6).random()
|
||||
|
||||
return when (randomInt) {
|
||||
1 -> R.drawable.dice_1
|
||||
|
||||
@ -50,7 +50,7 @@ class MainActivity : AppCompatActivity() {
|
||||
private fun rollDice() {
|
||||
// Toast.makeText(this, "button clicked",
|
||||
// Toast.LENGTH_SHORT).show()
|
||||
val randomInt = Random().nextInt(6) + 1
|
||||
val randomInt = (1..6).random()
|
||||
|
||||
val drawableResource = when (randomInt) {
|
||||
1 -> R.drawable.dice_1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user