Replace Storage.getMutablePokemon(slot) usages with Storage.getPokemon(slot).toMutablePokemon()
Use indexed access operator to get and set a pokemon
Rename deletePokemonto remoteAtand returns the removed pokemon
Remove Storage.index
interface Storage {
/**
* Return a [Pokemon] instance.
* @see Pokemon.toMutablePokemon
*
* Should throw an [IllegalStateException] if [index] isn't lower than [capacity]
*/
operator fun get(index: Int): Pokemon
}
interface MutableStorage : Storage {
/**
* Replaces the pokemon at the specified [index] in this storage with the specified [pokemon].
*
* Should throw an [IllegalStateException] if [index] isn't lower than [capacity]
*/
operator fun set(index: Int, pokemon: Pokemon)
/**
* Removes a pokemon at the specified [index] from the storage.
* Return the pokemon that has been removed.
*
* Should throw an [IllegalStateException] if [index] isn't lower than [capacity]
*/
fun removeAt(index: Int): Pokemon
}
Things to do:
Storage.getMutablePokemon(slot)
usages withStorage.getPokemon(slot).toMutablePokemon()
deletePokemon
toremoteAt
and returns the removed pokemonStorage.index