Created
April 29, 2019 09:24
-
-
Save hlung/d412fe6471b2982dd535150aa81caba8 to your computer and use it in GitHub Desktop.
Pokemon model classes in Kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.raywenderlich.pokelist | |
import kotlinx.serialization.Serializable | |
@Serializable | |
data class Pokemon( | |
val name: String, | |
val url: String | |
) | |
@Serializable | |
data class Pokedex( | |
val pokemon_entries: List<PokemonEntry> | |
) | |
@Serializable | |
data class PokemonEntry( | |
val entry_number: Int, | |
val pokemon_species: Pokemon | |
) { | |
@Transient | |
val label: String | |
get() { | |
val name = pokemon_species.name.toUpperCase() | |
val id = entry_number.padding(3) | |
return "N°$id\t\t$name" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment