用java用类描述时间_shuijing-cpu-java 用类描述计算机中CPU的速度和硬盘的容量。要求 应用程序有4个类,名字分别是PC、CP Develop 256万源代码下载- www.pud...

详细说明:用类描述计算机中CPU的速度和硬盘的容量。要求Java应用程序有4个类,名字分别是PC、CPU、HardDisk和Test,其中Test是主类。

 PC类与CPU和HardDisk类关联的UML图如下:

其中,CPU类要求getSpeed()返回speed的值,要求setSpeed(int m)方法将参数m的值赋值给speed。HardDisk类要求getAmount()返回amount的值,要求setAmount(int m)方法将参数m的值赋值给amount。PC类要求setCPU(CPU c)将参数c的值赋值给cpu,要求setHardDisk(HardDisk h)方法将参数h的值赋值给HD,要求show()方法能显示cpu的速度和硬盘的容量。

 主类Test的要求

(1)main方法中创建一个CPU对象cpu,cpu将自己的speed设置为2200;

(2)main方法中创建一个HardDisk对象disk,disk将自己的amount设置为200;

(3)main方法中创建一个PC对象pc;

(4)pc调用setCPU(CPU c)方法,调用时实参是cpu;

(5)pc调用setHardDisk(HardDisk h)方法,调用时实参是disk

(6)pc调用show()方法。-With class describes the computer CPU speed and hard drive capacity. Requirements Java application has four categories, names are PC, CPU, HardDisk and Test, where Test is the main class.  PC with UML class diagram CPU and HardDisk class association as follows: where, CPU type requires getSpeed ​ ​ () Returns the value of the speed, requiring setSpeed ​ ​ (int m) method of the value of the parameter m is assigned to speed. HardDisk class requires getAmount () Returns the value of the amount of required setAmount (int m) method parameter m is assigned to amount. PC class requires setCPU (CPU c) the value of the parameter c is assigned to cpu, requires setHardDisk (HardDisk h) method parameter values ​ ​ h is assigned to HD, requirements show () method can show cpu speed and hard drive capacity. Requirements  main class Test of (1) main method to create a CPU target cpu, cpu own speed is set to 2200 (2) main method to create a HardDisk targe

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值