modified random dice method to be a generic method
This commit is contained in:
parent
11d9705e5b
commit
5ecf349620
@ -3,16 +3,11 @@ package com.wyattjmiller.dicerollerapp
|
|||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
class Randomizer {
|
class Randomizer {
|
||||||
private var mCoin: Array<Coin> = Coin.values()
|
fun randomCoinFlip(item: Array<Coin>): Int {
|
||||||
private var mDie: Array<Die> = Die.values()
|
return Random.nextInt(item.size)
|
||||||
|
|
||||||
fun randomCoinFlip(): Int {
|
|
||||||
val rand = Random.nextInt(mCoin.size)
|
|
||||||
return rand
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun randomDieRoll(): Int {
|
fun <T : Die> randomDieRoll(item: Array<T>): Int {
|
||||||
val rand = Random.nextInt(mDie.size)
|
return Random.nextInt(item.size)
|
||||||
return rand
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user