PRO192_-_PE_-_SP_2025_3457.webp
Sakura_chan

PRO192_-_PE_-_SP_2025_3457.webp

Kizspy.me
Question 1:
(2 marks) Read PE instructions at the bottom of the exam paper.
Do not pay attention to real meaning of objects, variables and their values in the questions below.
Write a class named Engine with the following information:
Engine
-designer:String
-power:int
+Engine()
+Engine(designer:String,
power:int)
+getDesigner():String
+getPower():int
+setPower(power:int):void
Where:
⚫Engine() default constructor.
Engine(designer:String, power:int) constructor,
which sets values to designer and power.
⚫ getDesigner():String - returns the strings, created by
inserting power after the position of the second
character of the designer string.
getPower():int-return power.
⚫ setPower(power:int):void update power=new
power * n. (n is the number of letters in the designer
string)
The program output might look something like:
Enter designer: motor
Enter power: 22
1. Test getDesigner()
2. Test setPower()
Enter TC (1 or 2): 1
OUTPUT:
mo22tor
Do not format the result.
Enter designer: motor23
Enter power: 10
1. Test getDesigner()
2. Test setPower()
Enter TC (1 or 2): 2
Enter new power: 5
OUTPUT:
25
Zoom
+ 100%

Close
Chưa có bình luận nào.

Thông tin

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

Share this media

Back
Bên trên Bottom