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
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user