接口练习案例:防盗门
作者:互联网
接口练习案例:防盗门
- 防盗接口
package com.guoba.jiekoudemo;
public interface fangdao extends gongneng{
void fangdao();
}
- 功能接口
package com.guoba.jiekoudemo;
//包含防盗功能和防水功能
public interface gongneng {
void fangcheng();
void fangshui();
}
- 测试类
package com.guoba.jiekoudemo;
public class Test implements fangdao{
private int fangchenzhishu = 5;
private int fangshuishendu = 30;
public int getFangchenzhishu() {
return fangchenzhishu;
}
public void setFangchenzhishu(int fangchenzhishu) {
this.fangchenzhishu = fangchenzhishu;
}
public int getFangshuishendu() {
return fangshuishendu;
}
public void setFangshuishendu(int fangshuishendu) {
this.fangshuishendu = fangshuishendu;
}
@Override
public void fangcheng() {
System.out.println("防尘已开启,防尘质数:"+getFangchenzhishu());
}
@Override
public void fangshui() {
System.out.println("防水已开启,防水深度:"+getFangshuishendu());
}
@Override
public void fangdao() {
System.out.println("防盗已开启");
}
public static void main(String[] args) {
Test test = new Test();
test.fangdao();
test.fangcheng();
test.fangshui();
}
}
- 运行效果图
标签:fangchenzhishu,防盗门,void,练习,接口,fangdao,int,fangshuishendu,public 来源: https://www.cnblogs.com/guobabiancheng/p/15686176.html