2 of 3
Paper No: 1
-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 name:toshiba
Enter name:toshiba
Enter name:toshiba
Enter voltage:220
Enter voltage:220
Enter voltage:240
Enter current:0
1. Test toString
Enter voltage:220
Enter current:2
1. Test toString
Enter current:2
1. Test toString
2. Test getPower
Enter current:2
1. Test toString
2. Test getPower
2. Test getPower
2. Test getPower
3. Test set Voltage
3. Test set Voltage
3. Test set Voltage
3. Test set Voltage TO
Zoom
Close
+ 100%