运行结果如图所示,根据结果编写相应的接口、实现类以及测试类
public abstract class Door {
/**
* 功能:开门
* author:wangpeng
* time:2018年8月2日下午2:32:11
*/
public abstract void open();
/**
* 功能:关门
* author:wangpeng
* time:2018年8月2日下午2:32:23
*/
public abstract void close();
}
/**
* 防盗门接口
* 类名:AntiTheftDoor.java
* 作者:wangpeng
* 时间:2018年8月2日下午2:28:36
*/
public interface AntiTheftDoor {
/**
* 功能:防盗
* author:wangpeng
* time:2018年8月2日下午2:30:34
*/
void burglarproof();
/**
* 功能;门铃
* author:wangpeng
* time:2018年8月2日下午2:30:55
*/
void doorbell();
}
/**
* 消防门接口
* 类名:FireDoor.java
* 作者:wangpeng
* 时间:2018年8月2日下午2:28:06
*/
public interface FireDoor {
/**
* 功能:防火
* author:wangpeng
* time:2018年8月2日下午2:31:50
*/
void fire_prevention();
}
public class AntiTheftDoorT extends Door implements AntiTheftDoor{
@Override
public void burglarproof() {
// TODO Auto-generated method stub
System.out.println("防盗门有防盗的功能");
}
@Override
public void doorbell() {
// TODO Auto-generated method stub
System.out.println("防盗门有门铃的功能");
}
@Override
public void open() {
// TODO Auto-generated method stub
System.out.println("防盗门有开的功能");
}
@Override
public void close() {
// TODO Auto-generated method stub
System.out.println("防盗门有关的功能");
}
}
public class FireDoorT extends Door implements FireDoor{
@Override
public void fire_prevention() {
// TODO Auto-generated method stub
System.out.println("消防门有防火的功能");
}
@Override
public void open() {
// TODO Auto-generated method stub
System.out.println("消防门有开的功能");
}
@Override
public void close() {
// TODO Auto-generated method stub
System.out.println("消防门有关的功能");
}
}
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
AntiTheftDoorT antiTheft=new AntiTheftDoorT();
antiTheft.open();
antiTheft.close();
antiTheft.burglarproof();
antiTheft.doorbell();
FireDoorT fireDoor=new FireDoorT();
fireDoor.open();
fireDoor.close();
fireDoor.fire_prevention();
}
}