help me please :( | Sololearn: Learn to code for FREE!

+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

8/4/2021 7:36:02 AM

|[CNC]| ArCH. ExoTesla

10 Answers

New Answer

+5

|[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!

+4

But help you with what ?

+4

|[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!

+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

+3

Coding King. Lothar thank's friends... your's code help me succesfully...

+2

https://code.sololearn.com/cQg7CVOttYj5/?ref=app

+2

Lothar i'am a newbie :(

+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..

+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() }

+1

See this as well... https://code.sololearn.com/c34ueNmUq437/?ref=app