Answer to Question #327290 in HTML/JavaScript Web Application for hari

Question #327290

Mobile


i want code in between write code here



"use strict";

process.stdin.resume();

process.stdin.setEncoding("utf-8");

let inputString = "";

let currentLine = 0;

process.stdin.on("data", (inputStdin) => {

 inputString += inputStdin;

});

process.stdin.on("end", (_) => {

 inputString = inputString.trim().split("\n").map((str) => str.trim());

 main();

});

function readLine() {

 return inputString[currentLine++];

}

class Mobile {


  // Write your code here


}

function main() {

 const brand = readLine();

 const ram = readLine();

 const battery = parseInt(readLine());

 const song = readLine();

 const isOnCall = JSON.parse(readLine());


 const myMobile = // Write your code here

 

 myMobile.fullcharge(); 

 myMobile.playMusic();

 myMobile.stopMusic();

 myMobile.endCall();

 myMobile.makeCall();

 myMobile.endCall();

}


1
Expert's answer
2022-04-11T16:50:31-0400
"use strict";


process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;


process.stdin.on("data", (inputStdin) => {
 inputString += inputStdin;
});


process.stdin.on("end", (_) => {
 inputString = inputString.trim().split("\n").map((str) => str.trim());
 main();
});


function readLine() {
 return inputString[currentLine++];
}


class Mobile {
  constructor(brand,ram,battery,song,isOnCall){
    this.brand = brand;
    this.ram = ram;
    this.battery = battery;
    this.song = song;
    this.isOnCall = isOnCall;
  }
  
   fullcharge(){
   if(this.battery ===100){
      console.log("The battery was charged to the maximum");
      return;
   }
   this.battery = 100;
   console.log("Battery charge is maxed out");
  }
  
   playMusic(){
      console.log(this.song + " started playing");
    }
    
    stopMusic(){
      console.log(this.song + " finished playing");
    }
       endCall(){
      if(this.isOnCall){
        console.log("Call ended")
        this.isOnCall = false;
      }
    }
       makeCall(){
      if(this.isOnCall === false){
        console.log("Call started")
        this.isOnCall = true;
      }
    }
}


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,song,isOnCall);


 myMobile.fullcharge(); 
 myMobile.playMusic();
 myMobile.stopMusic();
 myMobile.endCall();
 myMobile.makeCall();
 myMobile.endCall();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS