October 2019
Intermediate to advanced
434 pages
11h 54m
English
Now, let's add the ability to add a pizza to our order, as well as configure it:
sealed class Topping(name: String): Item(name)object Pepperoni : Topping("Pepperoni")object Olive : Topping("Olive")object Pineapple : Topping("Pineapple")
sealed class Pizza(name: String) : Item(name) { val toppings: MutableList<Topping> = mutableListOf()}
This Pizza class extends Item and has a field, MutableList<Topping>, for storing our pizza toppings.
class BuildYourOwn(init: Pizza.() -> Unit = {}) : Pizza("Build Your Own Pizza") { init ...
Read now
Unlock full access