End of 'Classes'

This commit is contained in:
2020-03-03 18:37:04 -05:00
parent 8dcf7dd6bf
commit 01d373c5a7
7 changed files with 121 additions and 3 deletions

38
src/spice/Spice.kt Normal file
View File

@@ -0,0 +1,38 @@
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()
}
}