hi I'm new in android programming and i try to flip a coin for practice more roll.dice in kotlin so i wrote the code Bellow :
fun main(){
val myFirstDice=Dice(6)
println("Your ${myFirstDice.numSides} sided dice rolled ${myFirstDice.roll()}!")
val mySecondDice=Dice(20)
println("Your ${mySecondDice.numSides} sided dice rolled ${mySecondDice.roll()}!")
val myCoin=Coin(2)
println("Your ${myCoin.numSides} coin fliped ${myCoin.roll()}")
}
class Dice(val numSides :Int){
fun roll() : Int{
return (1..numSides).random()
}
class Coin(val numSides :Int) {
fun roll() :Int{
return (1..numSides).random()
}
}
}
but i have this problem : *Unresolved reference: Coin *
ty for helping me
You're missing the closing }
on your Dice
class. You need to be careful about copying everything - make sure every opening {
has a closing one in the right place (Android Studio draws a vertical line so you can see where the block closes)