手机

package com.day09;

public abstract class HandSet {
    private String brand;
    private String type;

    public HandSet(){}
    public HandSet(String brand,String type){
        this.brand = brand;
        this.type = 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 abstract void sendMess();

    //打电话
    public abstract void call();

    //手机信息介绍
    public void showInfo(){
        System.out.println("这是一台"+brand+type);
    }
}
package com.day09;

public interface NetWorking {
    void network();
}
package com.day09;

public interface Playing {
    void playVideo(String name);
}
package com.day09;

//拍照
public interface TakePhoto {
    void takePhoto();
}
package com.day09;
//普通手机
public class CommonPhone extends HandSet implements Playing {
    public CommonPhone(){}

    public CommonPhone(String brand,String type){
        super(brand,type);
    }

    public void playVideo(String name){
        System.out.println("播放音频:《"+name+">");
    }

    public void sendMess(){
        System.out.println("发送文字短信");
    }

    @Override
    public void call(){
        System.out.println("语音通话");
    }
}
package com.day09;

public class ZhinengPhone extends HandSet implements TakePhoto,NetWorking,Playing {
    public ZhinengPhone(){}

    public ZhinengPhone(String brand,String type){
        super(brand,type);
    }


    public void sendMess() {
        System.out.println("发送文字");
    }

    public void call() {
        System.out.println("通话");
    }

    public void network() {
        System.out.println("上网");
    }

    public void playVideo(String name) {
        System.out.println("播放视频《"+name+"》");
    }

    public void takePhoto() {
        System.out.println("拍照");
    }
}
package com.day09;

public class Test {
    public static void main(String[] args) {
        CommonPhone common = new CommonPhone("普通手机","a");
        common.call();
        common.sendMess();
        common.playVideo("111");
        common.showInfo();

        System.out.println("*****************");
        ZhinengPhone zhi = new ZhinengPhone("智能手机","b");
        zhi.call();
        zhi.sendMess();
        zhi.playVideo("222");
        zhi.network();
        zhi.takePhoto();
        zhi.showInfo();
    }
}

原文地址:https://www.cnblogs.com/zhangbupang/p/11221891.html