+ 1

help me please :(

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 https://code.sololearn.com/cQg7CVOttYj5/?ref=app

4th Aug 2021, 7:36 AM
|[CNC]| ArCH. ExoTesla
|[CNC]| ArCH. ExoTesla - avatar
10 Respostas
+ 5
But help you with what ?
4th Aug 2021, 8:00 AM
Abhay
Abhay - avatar
+ 4
|[CNC]| ArCH. ExoTesla , can you please be a bit more specific? maybe you expect us to send you a ready-made code. we will not do so, but the community is willing to help you with your problem. to do so, we need to see your code to find out where the issue is. => please put your code in playground and link it here. thanks!
4th Aug 2021, 8:12 AM
Lothar
Lothar - avatar
+ 4
|[CNC]| ArCH. ExoTesla , there are 2 issues in the code: ▪︎function add() in class MusicPlayer needs to be reworked (2 items) ▪︎main function was modified (may be by accident) AND: ▪︎the complete code has a real bad formatting, that makes it difficult to read and to maintain. here is the code reworked at the marked lines (//****) that should run properly : https://code.sololearn.com/ctVT1EPrGczk/?ref=app
5th Aug 2021, 10:18 AM
Lothar
Lothar - avatar
+ 4
Coding King. Lothar thank's friends... your's code help me succesfully...
5th Aug 2021, 4:07 PM
|[CNC]| ArCH. ExoTesla
|[CNC]| ArCH. ExoTesla - avatar
+ 3
|[CNC]| ArCH. ExoTesla , you have already done around 90 % of the kotlin tutorial and you also have completed various other language tutorials, so i don't think that you are a newbie. please be realistic. having this in mind, i am sure you can solve this exercise. take some time and effort, and do a try by yourself. if you get stuck, come back, show us your code and you will get help from the community. happy coding!
4th Aug 2021, 8:53 AM
Lothar
Lothar - avatar
4th Aug 2021, 8:24 AM
|[CNC]| ArCH. ExoTesla
|[CNC]| ArCH. ExoTesla - avatar
+ 1
Lothar i'am a newbie :(
4th Aug 2021, 8:25 AM
|[CNC]| ArCH. ExoTesla
|[CNC]| ArCH. ExoTesla - avatar
+ 1
Lothar looking my code, what's wrong.. I'm confused as to how I should fix it.. from here i feel i can't finish it..
5th Aug 2021, 2:57 AM
|[CNC]| ArCH. ExoTesla
|[CNC]| ArCH. ExoTesla - avatar
+ 1
Lothar looking it, show me what's wrong please.. class MusicPlayer { private var songs: Array<String> = arrayOf() //your code goes here fun add(track: String): Array<String>{ songs = songs + track return songs } fun show(){ for(track in songs.indices){ println(songs[track]) } } fun play(){ println("Playing "+songs[0]) } } fun main(args: Array<String>) { val m = MusicPlayer() while(true) { var input = readLine()!! if(input == "stop") { break } m.add(input) } m.show() m.play() }
5th Aug 2021, 3:09 AM
|[CNC]| ArCH. ExoTesla
|[CNC]| ArCH. ExoTesla - avatar
5th Aug 2021, 3:43 PM
Coding King.
Coding King. - avatar