智能手机和Psp都有玩游戏的功能
/javaDemo5/src/com/imooc/Telphone.java
package com.imooc; public abstract class Telphone { }
/javaDemo5/src/com/imooc/IPlayGame.java
package com.imooc; public interface IPlayGame { public void playGame(); }
/javaDemo5/src/com/imooc/SmartPhone.java
package com.imooc; public class SmartPhone extends Telphone implements IPlayGame { public void playGame() { // TODO Auto-generated method stub System.out.println("具有玩游玩的功能"); } }
/javaDemo5/src/com/imooc/Psp.java
package com.imooc; public class Psp implements IPlayGame { public void playGame() { // TODO Auto-generated method stub System.out.println("具有玩游玩的功能"); } }
/javaDemo5/src/com/imooc/Initail.java
package com.imooc; public class Initail { public static void main(String[] args) { IPlayGame ip1 = new SmartPhone(); ip1.playGame(); IPlayGame ip2 = new Psp(); ip2.playGame(); } }