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();
}
"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();
}
Comments
Leave a comment