zoukankan      html  css  js  c++  java
  • 计算机

    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();
        }
    }

  • 相关阅读:
    vscode里的NPM脚本
    Vue之生命周期activated与created使用
    分享10个超棒的设计素材网站
    使用node搭建静态资源服务器
    vue 动态组件的传值
    一文带你入门正则表达式
    一文告诉你git如何使用
    一文告诉你三种常见跨域解决方案
    一文告诉你原型与原型链是什么?
    一文告诉你 Event Loop 是什么?
  • 原文地址:https://www.cnblogs.com/zhangbupang/p/11222087.html
Copyright © 2011-2022 走看看