描述计算机中CPU速度和磁盘容量


public class PC {  

  
    private CPU cpu;  
    private HardDisk hardDisk;  
    public void setCpu(CPU cpu) {  
        this.cpu = cpu;  
    }  
    public void setHardDisk(HardDisk hardDisk) {  
        this.hardDisk = hardDisk;  
    }  
      
    public void show() {  
        System.out.println("CPU速度为"+cpu.getSpeed()+",磁盘容量为"+hardDisk.getAmount());  
    }  

}  


public class CPU {  
  
    private int speed;  
  
    public int getSpeed() {  
        return speed;  
    }  
  
    public void setSpeed(int speed) {  
        this.speed = speed;  
    }  
      
}  



public class HardDisk {  
  
    private int amount;  
  
    public int getAmount() {  
        return amount;  
    }  
  
    public void setAmount(int amount) {  
        this.amount = amount;  
    }  
      
}  



public class Test {  
    public static void main(String[] args) {  
          
        CPU cpu=new CPU();  
        cpu.setSpeed(2200);  
        HardDisk hardDisk=new HardDisk();         
        hardDisk.setAmount(200);  
          
        PC pc=new PC();  
        pc.setCpu(cpu);  
        pc.setHardDisk(hardDisk);  
          
        pc.show();  
    }  
}  描述计算机中CPU速度和磁盘容量

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2021-08-02
  • 2022-02-01
  • 2021-08-24
  • 2021-06-05
  • 2021-09-17
  • 2021-12-06
猜你喜欢
  • 2021-06-28
  • 2021-04-22
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
相关资源
相似解决方案