modified random dice method to be a generic method

This commit is contained in:
Wyatt J. Miller 2020-09-24 16:17:09 -04:00
parent 11d9705e5b
commit 5ecf349620

View File

@ -3,16 +3,11 @@ package com.wyattjmiller.dicerollerapp
import kotlin.random.Random
class Randomizer {
private var mCoin: Array<Coin> = Coin.values()
private var mDie: Array<Die> = Die.values()
fun randomCoinFlip(): Int {
val rand = Random.nextInt(mCoin.size)
return rand
fun randomCoinFlip(item: Array<Coin>): Int {
return Random.nextInt(item.size)
}
fun randomDieRoll(): Int {
val rand = Random.nextInt(mDie.size)
return rand
fun <T : Die> randomDieRoll(item: Array<T>): Int {
return Random.nextInt(item.size)
}
}