• 计算机


    package com.day10;
    
    public interface Cpu {
        public String Pingpai();
        public String ZhuPin();
    }
    package com.day10;
    
    public class CpuType implements Cpu {
        public String Pingpai(){
            return "Inter";
        }
        public String ZhuPin(){
            return "3.8";
        }
    }
    package com.day10;
    
    public interface Ems {
        public String Capacity();
    }
    package com.day10;
    
    public class EmsType implements Ems {
        public String Capacity(){
            return "16G";
        }
    }
    package com.day10;
    
    public interface HardDisk {
        public String Size();
    }
    package com.day10;
    
    public class HardDiskType implements HardDisk {
        public String Size(){
            return "500G";
        }
    }
    package com.day10;
    
    public class Computer {
        public Cpu getCpu() {
            return cpu;
        }
    
        public void setCpu(Cpu cpu) {
            this.cpu = cpu;
        }
    
        public Ems getEms() {
            return ems;
        }
    
        public void setEms(Ems ems) {
            this.ems = ems;
        }
    
        public HardDisk getHardDisk() {
            return hardDisk;
        }
    
        public void setHardDisk(HardDisk hardDisk) {
            this.hardDisk = hardDisk;
        }
    
        private Cpu cpu;
        private Ems ems;
        private HardDisk hardDisk;
    
        public Computer(){}
        public Computer(Cpu cpu,Ems ems,HardDisk hardDisk){
            super();
            this.cpu = cpu;
            this.ems = ems;
            this.hardDisk = hardDisk;
        }
    
        public void print(){
            System.out.println("计算机的信息:");
            System.out.println("cpu品牌是"+cpu.Pingpai()+",主频是"+cpu.ZhuPin());
            System.out.println("内存的容量是"+ems.Capacity());
            System.out.println("硬盘容量是"+hardDisk.Size());
        }
    
    
    }
    package com.day10;
    
    public class Test {
        public static void main(String[] args) {
            Cpu cpu = new CpuType();
            Ems ems = new EmsType();
            HardDisk hardDisk = new HardDiskType();
            Computer computer = new Computer(cpu,ems,hardDisk);
            computer.print();
        }
    }

  • 相关阅读:
    02-30 线性可分支持向量机
    02-28 scikit-learn库之线朴素贝叶斯
    02-27 朴素贝叶斯
    02-26 决策树(鸢尾花分类)
    047 选项模式
    第二节:师傅延伸的一些方法(复习_总结)
    第一节:登录流程
    第一节:对应拼音编码查询(后续更新)
    前端对象
    Form表单
  • 原文地址:https://www.cnblogs.com/zhangbupang/p/11222087.html
Copyright © 2020-2023  润新知