unity——C#多接口类继承

C#多接口类继承

父类

[csharp]  view plain copy
  1. using UnityEngine;  
  2. using System.Collections;  
  3.   
  4. public class Vehicle {  
  5.     private float Speed;  
  6.     private float MaxSpeed;  
  7.     private float Weight;  
  8.     public void Run()  
  9.     {  
  10.         Debug.Log("Vehicle-Run");  
  11.     }  
  12.     public float speed{  
  13.         set{  
  14.             Speed=value;  
  15.         }  
  16.         get{  
  17.             return Speed;  
  18.         }  
  19.         }  
  20.     public float maxspeed{  
  21.         set{  
  22.             MaxSpeed=value;  
  23.         }  
  24.         get{  
  25.             return MaxSpeed;  
  26.         }  
  27.     }  
  28.     public float weight{  
  29.         set{  
  30.             Weight=value;  
  31.         }  
  32.         get{  
  33.             return Weight;  
  34.         }  
  35.     }  
  36.     public void Stop()  
  37.     {  
  38.         Debug.Log("Vehicle-Stop");  
  39.     }  
  40. }  

子类+接口继承

[csharp]  view plain copy
  1. using UnityEngine;  
  2. using System.Collections;  
  3.   
  4. interface chj  
  5. {  
  6.     void bbb();  
  7. }  
  8. interface chj1  
  9. {  
  10.     int ccc();  
  11.     void bbb();  
  12. }  
  13. interface chj2:chj  
  14. {  
  15.     void ced();  
  16. }  
  17. public class jiekou:Vehicle,chj1,chj2 {  
  18.     public int a;  
  19.     void chj.bbb()  
  20.     {  
  21.         Debug.Log ("chj->bbb");  
  22.   
  23.     }  
  24.     void chj1.bbb()  
  25.     {  
  26.         Debug.Log ("chj1->bbb");  
  27.           
  28.     }  
  29.     public void ced()  
  30.     {  
  31.   
  32.     }  
  33.     public int ccc()  
  34.     {  
  35.         a = 100;  
  36.         return a;  
  37.     }  
  38. }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值