模拟打印机

package zuoye01;

public interface Color {

    public String caiShe();
}


package zuoye01;

public interface HeiBai {

    
    public String heiBai();
}


package zuoye01;

public class Int_Color implements Color,HeiBai{

    @Override
    public String heiBai() {
        // TODO Auto-generated method stub
        
        return "黑白";
    }

    @Override
    public String caiShe() {
        // TODO Auto-generated method stub
        return "彩色";
    }

    
    
    
}

 

 

 

package zuoye01;

public interface Size01 {

    
    public String A4();
}


package zuoye01;

public interface Size02 {

    public String B5();
    
}
package zuoye01;

public class PrintSize implements Size01,Size02{

    @Override
    public String B5() {
        // TODO Auto-generated method stub
        return "B5";
    }

    @Override
    public String A4() {
        // TODO Auto-generated method stub
        return "A4";
    }
    
    

}
//印刷机    要实现印刷大小 和 印刷出的颜色    应该再弄一个专门加工印刷纸的工厂
//以及再弄一个印刷颜色的工厂    实现出来拼装出来两个   再把这两个分别实现
package zuoye01;

import java.util.Scanner;

public class printer {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String mouHe_Color = null;
        String printSize = null;
        
        System.out.println("请选择印刷纸大小(A4和B5)");
        String choose01 = sc.next();
        PrintSize daXiao = new PrintSize();
        if ("A4".equals(choose01)) {
             printSize = daXiao.A4();
        } else if ("B5".equals(choose01)) {
            printSize = daXiao.B5();
        }

        System.out.println("请选择印刷颜色(黑白和彩色)");
        Int_Color mouHe = new Int_Color();
        String choose02 = sc.next();

        if ("黑白".equals(choose02)) {
             mouHe_Color = mouHe.heiBai();
        } else if ("彩色".equals(choose02)) {
             mouHe_Color = mouHe.caiShe();

        }
        System.out.println("-----------------\n");
        System.out.println("正在使用"+mouHe_Color+"颜色在"+printSize+"上打印");
        
    }

}

 

 

posted @ 2019-07-19 17:38  AxeBurner  阅读(254)  评论(0编辑  收藏  举报