I'm trying to make a simple card game to get more used to classes in Kotlin, but something Is wrong, here's the code:
class Cards(val cardName: String = "", cardValue: Int = 0, amountDeck: Int = 4) {}
public var allCards = listOf<Cards>(
Cards("One", 1),
Cards("Two", 2),
Cards("Three", 3),
Cards("Four", 4),
Cards("Five", 5),
Cards("Six", 6),
Cards("Seven", 7),
Cards("Eight", 8),
Cards("Nine", 9),
Cards("Ten", 10),
Cards("Eleven", 11),
Cards("Twelve", 12),
Cards("Ace", 10),
Cards("Queen", 10),
Cards("Jack", 10),
Cards("King", 10)
)
fun drawCard(randomValue: Int) {
val currentName: String = allCards[randomValue].cardName
val currentValue: Int = allCards[randomValue].cardValue
}
I can get the cardName value from the list, but when I try to get the cardValue it just says: unresolved reference: cardValue
What am I doing wrong?