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

Command

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

fun interface ICommand {
    operator fun invoke()
}
fun main() {
    val copyCommand = CopyCommand()
    val scanCommand = ScanCommand()
    val printCommand = PrintCommand()

    val printer = Invoker(copyCommand)
    printer.execute()

    printer.command = scanCommand
    printer.execute()

    printer.command = printCommand
    printer.execute()
}

Last updated

Was this helpful?