PRO192_-_PE01_-_SU_2024_2179.webp
Vân Anh1

PRO192_-_PE01_-_SU_2024_2179.webp

-current:int
+ElectricMotor()
+ElectricMotor(name:String, voltage:int,
current:int)
+getName():String
+getPower():int
+setVoltage(voltage:int): void
+toString():String
ElectricMotor(name: String, voltage:int,current:int) parameterized constructor,which sets values to name, voltage and current of the electric motor. If the voltage is greater than 220 or less than 110, set it to 120. If the current is less or equal to 0, set it to 1
getName(): String - return the name
getPower(): int return the motor power,with the power = voltage * current
setVoltage(voltage:int):void update the voltage if the voltage is from 110 to 220
toString():String: return a string format that contains all the information of the ElectricMotor: name, voltage, current,power. The name in uppercase
Do not format the result.
The main class is ready to test the program. The program output might look something like:
Enter name:toshiba
Enter voltage:220
Enter current:2
1. Test toString
2. Test getPower
3. Test set Voltage Enter TC (1, 2 or 3):1
OUTPUT:TOSHIBA, 220, 2, 440
Enter name:toshiba
Enter voltage:220
Enter current:2
1. Test toString
2. Test getPower
3. Test set Voltage
Enter TC (1, 2 or 3):2
OUTPUT:440
Enter name:toshiba
Enter voltage:240
Enter current:0
1. Test toString
2. Test getPower
3. Test set Voltage
Enter TC (1, 2 or 3):2
OUTPUT:120
Enter name:toshiba
Enter voltage:220
Enter current:2
1. Test toString
2. Test getPower
3. Test set Voltage
Enter TC (1, 2 or 3):3
Enter new voltage:110
OUTPUT:TOSHIBA, 110, 2, 220
Zoom
+ 100%
Close
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
Vân Anh1
Ngày thêm
Lượt xem
6,124
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
PRO192_-_PE01_-_SU_2024_2179.webp
File size
282 KB
Dimensions
1920px x 990px

Share this media

Back
Bên trên Bottom