Complete the code to declare an enum class named Direction.
enum class [1] { NORTH, SOUTH, EAST, WEST }
The enum class must be named with a capitalized identifier, here Direction, to follow Kotlin conventions.
Complete the code to access the enum value EAST.
val dir = Direction.[1]Enum constants in Kotlin are uppercase by convention, so EAST is correct.
Fix the error in the code to assign a valid enum value to variable dir.
val dir: Direction = Direction.[1]Only the enum constants declared in Direction can be assigned. NORTH is valid; others are not declared.
Fill both blanks to create a function that returns true if the direction is WEST.
fun isWest(dir: Direction): Boolean = dir [1] Direction.[2]
The function compares if dir is equal to Direction.WEST using ==.
Fill all three blanks to create a when expression that returns a message for each direction.
fun directionMessage(dir: Direction): String = when(dir) {
Direction.NORTH -> "Go [1]"
Direction.SOUTH -> "Go [2]"
Direction.EAST -> "Go [3]"
else -> "Stay still"
}The messages correspond to the direction names in lowercase matching each enum constant.