PRO192_-_PE01_-_SU_2024_2179.webp
Vân Anh1

PRO192_-_PE01_-_SU_2024_2179.webp

• All source code files .java in the projects will be created in the default package of the NetBean
Question 1: (2 marks)
Do not pay attention to the real meaning of objects, variables, and their values in the questions below.
Write a class ElectricMotor with the following information:
ElectricMotor
Where:
-name:String
ElectricMotor() - default constructor.
-voltage:int
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
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
8,424
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
233.6 KB
Dimensions
1920px x 990px

Share this media

Back
Bên trên Bottom