Skip to content

Instantly share code, notes, and snippets.

@PraveenMathew92
Last active August 3, 2021 12:05
Show Gist options
  • Save PraveenMathew92/5ef597850cee8aa7dff171c5d9a1d7c5 to your computer and use it in GitHub Desktop.
Save PraveenMathew92/5ef597850cee8aa7dff171c5d9a1d7c5 to your computer and use it in GitHub Desktop.
data class Customer(private val firstName: String,
private val lastName: String,
private val age: Int) {
private val fullName = "$firstName $lastName"
fun isAdult(): Boolean {
return age >= 18
}
fun getGreetingName(): String {
return if (isAdult()) fullName else firstName
}
}
class FrontEnd {
fun display(message: String) {
// code to display the message on the Frontend device
}
}
class DriversLicenseService {
private val frontEnd = FrontEnd()
private val driverLicenseApi = DriverLicenseApi
public fun greetCustomer(customer: Customer){
val greetingMessage = "Good day, ${customer.getGreetingName()}"
frontEnd.display(greetingMessage)
}
public fun getDriversLicense(customer: Customer) {
if(!customer.isAdult()) {
throw CustomerNotAdultException(customer)
}
// code to get the driver license for the customer from external api (or a database)
return driverLicenseApi.getDriverseLicenseFor(customer.id)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment