Skip to content

Instantly share code, notes, and snippets.

@markchristopherng
Last active February 18, 2020 23:55
Show Gist options
  • Save markchristopherng/3ae0e93fb24b66e245fcdd668938b490 to your computer and use it in GitHub Desktop.
Save markchristopherng/3ae0e93fb24b66e245fcdd668938b490 to your computer and use it in GitHub Desktop.
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