Home > Back-end >  With class description in the computer CPU speed and hard drive capacity. Requires Java applications
With class description in the computer CPU speed and hard drive capacity. Requires Java applications

Time:11-27

Described in class in the computer CPU speed and hard drive capacity, requires a Java application has four class, name, respectively is a PC, CPU and HardDisk and Test, the Test is the main class,
? PC with CPU and HardDisk associated UML diagram (figure 4.33)
Among them, the CPU class requirements getSpeed () returns the value of speed; Request setSpeed m (int) method of the parameter m value assigned to speed, HardDisk class requirements getAmount () returns the value of the amount, require setAmount m (int) method of the parameter m value assigned to the amount, PC class requirements setCUP CPU (c) the parameter c value assigned to the CPU, require setHardDisk (HardDisk h) method of the parameter h value assigned to the HD, show () method can display the CPU speed and hard drive capacity,
? The requirements of the main class Test
(1) the main method of creating a CPU object CPU, CPU will own speed is set to 2200,
(2) the main method of creating a HardDisk object disk, disk set their own amount to 200,
(3) the main method to create a PC, PC object
(4) PC call setCUP (CPU c) method, called argument is CPU,
5 PCS call setHardDisk (HardDisk h) method, called argument is a disk,
6 PCS call show () method,
Modify the experiment of 8 code for
1. A PC can have multiple hard disks, multiple cpus
2. You can add and remove the CPU
3.
can add and remove the hard drive4. Can be displayed in the PC's CPU and hard disk information


  • Related