java 接口实现防盗门功能

时间:2021-06-20 04:16:21

Door;

package locker;

public abstract class Door {
public abstract void open();
public abstract void close();
}

Lock:

package locker;

public interface  Lock {
void lockUp();//开锁
void openLock();
}

Security:

package locker;

public class Security extends Door implements Lock {
@Override
public void lockUp() {
System.out.println("关锁");
} @Override
public void openLock() {
System.out.println("开锁");
} @Override
public void open() {
System.out.println("门开了");
} @Override
public void close() {
System.out.println("门关了");
} }

Test;

package locker;

public class Text {
public static void main(String[] args) {
Security door = new Security();
door.close();
door.lockUp();
door.openLock();
door.open();
}
}

java 接口实现防盗门功能