Last active
February 18, 2020 23:55
-
-
Save markchristopherng/3ae0e93fb24b66e245fcdd668938b490 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface GreetingService { | |
fun greetings(): String | |
} | |
class GreetingServiceImpl(private val messageData: MessageData, private val timeService: TimeService) : | |
GreetingService { | |
override fun greetings(): String { | |
val timeOfDay = when (timeService.getHourOfDay()) { | |
in 7..11 -> "morning" | |
in 17..23 -> "evening" | |
else -> "day" | |
} | |
return "Good $timeOfDay, ${messageData.welcomeMessage}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment