实现手机的某些功能
---恢复内容开始---
//父类
package zuoye;
public abstract class Phone {
// 属性 品牌 类型
private String pinpai;
private String leiXin;
public String getPinpai() {
return pinpai;
}
public void setPinpai(String pinpai) {
this.pinpai = pinpai;
}
public String getLeiXin() {
return leiXin;
}
public void setLeiXin(String leiXin) {
this.leiXin = leiXin;
}
// 方法
public void call() {
System.out.println("打电话");
}
public void faXinXin() {
System.out.println("发信息");
}
public void shouXinXin() {
System.out.println("收信息");
}
}
//播放功能接口 package zuoye; public interface BouFang { public void BouFang(); } //连接wife接口 package zuoye; public interface LinWife { public void linWife(); } package zuoye; //智能手机实现照相和连接网络 public class Zhineg extends Phone implements ZhaoXiang,LinWife,BouFang{ @Override public void linWife() { // TODO Auto-generated method stub System.out.println("连接网络"); } @Override public void zhaoXian() { // TODO Auto-generated method stub System.out.println("照相网络"); } @Override public void BouFang() { // TODO Auto-generated method stub System.out.println("播放音频"); } }
//实现照明功能的接口 package zuoye; public interface ZhaoXiang { public void zhaoXian(); } //实现类 拼装 package zuoye; public class PuTong extends Phone implements BouFang{ @Override public void BouFang() { // TODO Auto-generated method stub System.out.println("播放音频"); } }
//测试类 package zuoye; public class Test { public static void main(String[] args) { PuTong p = new PuTong(); p.BouFang(); p.call(); p.faXinXin(); p.shouXinXin(); System.out.println("----------\n"); Zhineg z = new Zhineg(); z.linWife(); z.zhaoXian(); z.call(); z.faXinXin(); z.shouXinXin(); z.BouFang(); } }
---恢复内容结束---