This repository has been archived on 2025-11-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
learn-kotlin/src/spice/Spice.kt
2020-03-03 18:37:04 -05:00

38 lines
743 B
Kotlin

package spice
enum class Color(val rgb: Int) {
RED(0xFF0000),
GREEN(0x00FF00),
BLUE(0x0000FF),
YELLOW(0xFFFF00);
}
sealed class Spice(val name: String, val spiciness: String = "mild", color: SpiceColor) : SpiceColor by color {
abstract fun prepareSpice()
}
interface Grinder {
fun grind()
}
interface SpiceColor {
val color: Color
}
object YellowSpiceColor : SpiceColor {
override val color = Color.YELLOW
}
data class SpiceContainer(val spice: Spice) {
val label = spice.name
}
class Curry(name: String, spiciness: String, color: SpiceColor = YellowSpiceColor):
Spice(name, spiciness, color), Grinder {
override fun grind() {
}
override fun prepareSpice() {
grind()
}
}