Lev1

导航

防盗门

门类

package cn.door1;
//
public abstract class Door {
    //开门
    public abstract void open();
    //关门
    public abstract void close();

}

接口类

package cn.door1;
//锁类
public interface Lock {
        public void Openlock();//
        public void Closelock();//
}
package cn.door1;
//照片类
public interface TakePhotos {
        public void takePhotos();
}

防盗门

package cn.door1;
//防盗门
public class TheftProofDoor extends Door implements Lock,TakePhotos{
    public void Openlock() {
        System.out.println("插进钥匙,往右转三圈,打开了.............");
    }

    public void Closelock() {
        System.out.println("插进钥匙,往左转三圈,锁上了.............");
    }
    public void open() {
        System.out.println("开门");
    }
    public void close() {
        System.out.println("关门");
    }
    public void takePhotos() {
        System.out.println("有人来访,拍照存档");
    }

}

测试类

package cn.door1;

public class Test {
        public static void main(String[] args) {
            TheftProofDoor door = new TheftProofDoor();
            System.out.println("回家");
            door.Openlock();
            door.open();
            System.out.println("************************************************************************");
            door.takePhotos();
            System.out.println("出门");
            door.close();
            door.Closelock();
        }
}

 

posted on 2019-07-22 12:13  Lev1  阅读(180)  评论(0编辑  收藏  举报