Реализации на Kotlin

Adapter

Общая реализация на языке Kotlin

interface IThermometer {
    val temperature: Double
}
fun main() {
    val thermometer: IThermometer = CelsiusThermometer()
    println("Temperature in celsius: ${thermometer.temperature}")
    val adapter: ITempAdapter = FahrenheitTempAdapter(thermometer)
    println("Temperature in fahrenheit: ${adapter.temperature}")
}

Last updated

Was this helpful?