Q1_20251109113146.webp
D

Q1_20251109113146.webp

4 of 5
10
Paper No: 1
0
Question 4:
(2 marks)
The given Q4.cpp file contains statements about input and output data of objects from the
Speaker class. You should write the statements to complete the Speaker class as described
below:
Speaker
Where:
-id: int
- brand: string
power: double
+Speaker(id:int, brand:string, power:double)
+getPowerLevel():double
+changeVolume(percent:int):void
+printInfo():void
• Speaker(id:int,
brand:string,
power:double) constructor, which
sets values to id, brand, and power
return
⚫getPowerLevel():double
the power
⚫ changeVolume(int percent): void -
increases or decreases the current
power by a percentage. Formula:
power power *(1+ percent/100)
- For example, if the current power is
200 and change Volume(10) is called,
the new power becomes 220.
If change Volume(-10) is called, the
new power becomes 180.
Zoom
- FUO
+ 100%
Close
Chưa có bình luận nào.

Thông tin

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

Share this media

Back
Bên trên Bottom