Mobile in javascript assignment expert

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,

MethodDescriptionchargingWhen 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 removeChargingremoveChargingIt should log "Please remove charging"playMusicIt should log a text with the song, as shown in the sample outputstopMusicIt should log "Music Stopped"makeCallWhen this method is called, it should set the value of the isOnCall to true and log "Calling ..."endCallWhen 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

  • The first line of input contains a string brand
  • The second line of input contains a string ram
  • The third line of input contains a number battery
  • The fourth line of input contains a string song
  • The fifth line of input contains a boolean isOnCall
  • The first line of output is a string containing
  • battery before charging, as shown in the sample outputs
  • The second line of output is a string based on
  • battery, as shown in the sample outputs
  • The third line of output is a string containing
  • song, as shown in the sample outputs
  • The fourth line of output is a string "Music stopped"
  • The fifth line of output is a string "No ongoing call to end" or "Call Ended"
  • The sixth line of output is a string "Calling..."
  • The seventh line of output is a string "Call Ended"

0 {

 inputString = inputString.trim[].split["\n"].map[[str] => str.trim[]];

 main[];

}];

function readLine[] {

 return inputString[currentLine++];

}

/* Please do not modify anything above this line */

class Mobile {

 /*

  * Write your code here

  */

}

/* Please do not modify anything below this line */

function main[] {

 const brand = readLine[];

 const ram = readLine[];

 const battery = parseInt[readLine[]];

 const song = readLine[];

 const isOnCall = JSON.parse[readLine[]];

 const myMobile = new Mobile[brand, ram, battery, isOnCall, song];

 console.log[`Mobile charged ${myMobile.battery}%`];  // The Mobile battery charged percentage

 myMobile.charging[]; // The Mobile charging

 myMobile.playMusic[]; // The Mobile will start playing a song

 myMobile.stopMusic[]; // The Mobile will stop playing a song

 myMobile.endCall[]; // The Mobile will end a call.

 myMobile.makeCall[]; // The Mobile will make a call.

 myMobile.endCall[]; // The Mobile will end a call.

}

Chủ Đề