下面是代码示例:主要实现方式关键字by
package com.lyc.myeight.interfaces interface ZuFang { fun KanFang() fun DingJia(int: Int) fun QianHeTong() }
package com.lyc.myeight import android.nfc.Tag import android.util.Log import com.lyc.myeight.interfaces.ZuFang class Fangdong:ZuFang { companion object{ val TAG="testlyc" } override fun KanFang() { Log.d(TAG,"kan") } override fun DingJia(int: Int) { Log.d(TAG,"一个月租金: $int") } override fun QianHeTong() { Log.d(TAG,"签合同") } }
package com.lyc.myeight import android.util.Log import com.lyc.myeight.interfaces.ZuFang class ZhongJie(fangdong: Fangdong):ZuFang by fangdong{ var mtip=0 private val mfabfdong=fangdong fun give(tip:Int){ mtip=tip } override fun KanFang() { if (mtip>200){ mfabfdong.KanFang() }else{ L