zoukankan      html  css  js  c++  java
  • java工厂模式---计算机 手机

    手机

    package com.shouji;
    
    import com.zhinengshouji.ZhaoXiang;
    import com.zhinengshouji.ZhiPhoto;
    
    //测试类
    public class Test {
        public static void main(String[] args) {
            Photo pu = new PuPhoto("索尼爱立信","G502c");
            System.out.println("这是一款"+pu.getName()+",型号为:"+pu.getType()+"的手机");
            pu.sendInfo();
            pu.info();
            pu.call();
            
            System.out.println("**************");
            
            Photo zhi = new ZhiPhoto("I9100","HTC");
            ZhiPhoto zh = (ZhiPhoto)zhi;
            System.out.println("这是一款"+zh.getName()+"的智能手机,型号为:"+zh.getType()+"的手机");
            zh.shangWang();
            zh.boFang();
            zh.zhaoXiang();
            zh.info();
            zh.call();
        }

    计算机

    package com.computer;
    
    import com.cpu.*;
    import com.cpu.Type;
    import com.ems.Ems;
    import com.ems.NeiCun;
    import com.harddisk.HardDisk;
    import com.harddisk.YNeiCun;
    
    //测试类
    public class Test {
        public static void main(String[] args) {
            Computer com = new Computer();
            Cpu cpu = new Type();
            com.setCpu(cpu);
            com.setZhuPin(cpu);
            NeiCun ems = new NeiCun();
            com.setEms(ems);
            YNeiCun  hardDisk = new YNeiCun();
            com.setHardDisk(hardDisk);
            com.showInfo();
        }
    }

  • 相关阅读:
    Jsp补充
    Jsp和Servlet关系
    ServletContext简介
    利用Session实现三天免登陆
    Cookie简介
    JSP简介
    线程基础--同步机制
    深思——工作面试
    response.setcontenttype的參数
    Codeforces 96D Volleyball spfa
  • 原文地址:https://www.cnblogs.com/zxbaoer/p/10396228.html
Copyright © 2011-2022 走看看