0

How to solve this?

You are building a Music Player app. You need to implement the MusicPlayer class, which should hold the track names as Strings in an array. The array is already defined in the given code. The player should support the following functions: add: add the given argument track to the tracks array. show: output all track names in the player on separate lines. play: start playing the first track by outputting "Playing name" where name is the first track name. You can add a new item to an array using +=, for example: tracks += track The code in main takes track names from user input and calls the player functions. Do not modify the code in main. //code// class MusicPlayer { private var songs: Array<String> = arrayOf() //your code goes here } fun main(args: Array<String>) { val m = MusicPlayer() while(true) { var input = readLine()!! if(input == "stop") { break } m.add(input) } m.show() m.play() }

17th Jul 2021, 1:03 PM
Ehthisham Mohammed
Ehthisham Mohammed - avatar
1 Odpowiedź
+ 1
Wonderful answer. I'll try that. Thank you so much!
17th Jul 2021, 3:17 PM
Ehthisham Mohammed
Ehthisham Mohammed - avatar