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(); } }