package com.day06; /* * 父类手机 */ public class Shouji { private String brand; private String type; public String getBrand() { return brand; } public void setBrand(String brand) { this.brand = brand; } public String getType() { return type; } public void setType(String type) { this.type = type; } public void call() { System.out.println("通话功能"); } public void faXinxi() { System.out.println("发信息"); } public void shouXinxi() { System.out.println("收信息"); } }
package com.day06; /* * 照相接口 */ public interface Zhaoxiang { public void zhaoXiang(); }
package com.day06; /* * 上网接口 */ public interface Lianwifi { public void lianwifi(); }
package com.day06; /* * 智能手机--子类 */ public class Zhineng extends Shouji implements Zhaoxiang,Lianwifi,Bofang{ @Override public void lianwifi() { // TODO Auto-generated method stub System.out.println("连接wifi"); } @Override public void zhaoXiang() { // TODO Auto-generated method stub System.out.println("照相"); } @Override public void bofang() { // TODO Auto-generated method stub System.out.println("播放视频"); } }
package com.day06; /* * 播放接口 */ public interface Bofang { public void bofang(); }
package com.day06; /* * 普通手机--子类 */ public class Putong extends Shouji implements Bofang{ @Override public void bofang() { // TODO Auto-generated method stub System.out.println("播放视频"); } }
package com.day06; /* * 测试类 */ public class Test { public static void main(String[] args) { Zhineng z = new Zhineng(); System.out.println("智能手机功能:"); z.call(); z.faXinxi(); z.shouXinxi(); z.lianwifi(); z.zhaoXiang(); z.bofang(); System.out.println("--------------------------------"); System.out.println("普通手机功能"); Putong p = new Putong(); p.bofang(); p.call(); p.faXinxi(); p.shouXinxi(); } }