Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun main() {
- val cat = Cat("cat")
- val wall = Wall("wall")
- wall.action(cat)
- }
- interface Jumping {
- fun jump(element: Wall)
- }
- interface Action<T> {
- fun action(member: T)
- }
- class Wall(val name: String) : Action<Jumping> {
- override fun action(member: Jumping) {
- member.jump(this)
- }
- }
- class Cat(val name: String) : Jumping {
- override fun jump(element: Wall) {
- print("${this.name} сделал прыжок через ${element.name}")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment