Mobile
You are given an incomplete
Mobile class.A Mobile object created using the
Mobile class should have the properties like brand, ram, battery, isOnCall, and song.Implement the
Mobile class to initialize the mentioned properties and add the following methods,
Method:- charging
Description:- When this method is called, it should set the value of the battery to 100, if the battery is already 100 then log "Mobile Fully Charged" and call removeCharging
method:- removeCharging
Description:- It should log "Please remove charging".
method:- playMusic
Description:- It should log a text with the song, as shown in the sample output
method:- stopMusic
Description:- It should log "Music Stopped"
method:- makeCall
Description:- When this method is called, it should set the value of the isOnCall to true and log
"Calling ..."
method:- endCall
Description:- When this method is called, it should log "No ongoing call to end" if isOnCall is false, else log "Call Ended" and set the value of the isOnCall to false.
0 <=
battery <= 100
Sample Input 1
Apple
2 GB
90
Waka Waka
false
Sample Output 1
Mobile charged 90%
Mobile charged 100%
Playing Waka Waka song
Music stopped
No ongoing call to end
Calling...
Call Ended
Sample Input 2
Samsung
8 GB
100
Gangnam Style
true
Sample Output 2
Mobile charged 100%
Mobile is fully charged
Please remove charging
Playing Gangnam Style song
Music stopped
Call Ended
Calling...
Call Ended
Comments
Leave a comment