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 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
} }
} }