Arama butonu
Bu konudaki kullanıcılar: 1 misafir
6
Cevap
319
Tıklama
0
Öne Çıkarma
Java stack şarkı listesi yardımı
G
8 yıl (1449 mesaj)
Binbaşı
Konu Sahibi

Write an object oriented program for “Media Player” that alphabetically sorts the songs in the
playlist by using two stacks.
A song has some features like name, singer and recorded year.
Example:
Song[] s = new Songs[4];
s[0] = new Song(“Good bye my lover”, “James Blunt”, 2006);
s[1] = new Song(“Rolling in the deep”, “Adele Laurie Blue Adkins”, 2010);
s[2] = new Song(“I have nothing”, “Whitney Houston”, 1992);
s[3] = new Song(“Better than you”, “Metallica”, 1999);
Hint: Create Song class and Playlist class. Sorting method must be in the playlist class.


Kodda bazı hatalarım var düzeltebilecek olan varsa kodu atabilirim dm den

DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.

Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.

Üye Ol Şimdi Değil



G
8 yıl (1449 mesaj)
Binbaşı
Konu Sahibi

upppp



G
8 yıl (1449 mesaj)
Binbaşı
Konu Sahibi

uppppp



G
8 yıl (1449 mesaj)
Binbaşı
Konu Sahibi

Yokmu yardım edebilecekkk



G
8 yıl (193 mesaj)
Teğmen

Kodu yazsana buraya, nerden görecek millet ?





< Bu mesaj bu kişi tarafından değiştirildi Glitch -- 17 Temmuz 2018; 13:50:13 >

< Bu ileti mobil sürüm kullanılarak atıldı >
Bu mesaja 1 cevap geldi.
G
8 yıl (1449 mesaj)
Binbaşı
Konu Sahibi

public class MediaPlayer {
private Song[] songs;
private int count;
private String playlistName;



public MediaPlayer() {
songs = new Song[4];
count = 0;
}
public String getPlaylistName() {
return playlistName;
}
public void setPlayListName() {
this.playlistName = playlistName;
}

public void add(Song s) {
if(count == songs.length) {
System.out.println("ERROR: Collection is full.");
}
songs[count] = s;
count++;
}

public Song get(int i) {
if(count > i) {
return songs;
}
else {
return null;
}
}


public void print() {
String result = "NumSongs = " + count
+ " / PlayList song limit = " + songs.length + "\n";

for (int i=0; i<count; i++) {
result += ("songList[" + i + "] = <"
+ songs + ">\n");
}
System.out.println(result.toString() + "\n");
}
public int size() {
return count;
}

public void clear() {
for (int i=0; i<songs.length; i++) {
songs = null;
count = 0;
}
return ;
}





/*


private String Sorting()
{
Stack stc= new Stack(10);
s1.push(songs);
while(!s1.isEmpty())
{

for(int i=0;i<=stc.size();i++){
if(song.compareTo(i)==song.compareTo(i+)){
stc.push(songs);

}

}


}

stc.push(number);

String result = "";

while(!s1.isEmpty())
{
result += stc.pop();
}

return result;*/


}



/******/



public class Song {
private String name;
private String singer;
private int recordedYear;



public Song(String name, String singer, int recordedYear) {

this.name = name;
this.singer = singer;
this.recordedYear = recordedYear;

}

public String getName() {
return name;
}



public void setName(String name) {
this.name = name;
}



public String getSinger() {
return singer;
}



public void setSinger(String singer) {
this.singer = singer;
}




public int getRecordedYear() {
return recordedYear;
}



public void setRecordedYear(int recordedYear) {
this.recordedYear = recordedYear;
}



public Song[] getSongs() {
return songs;
}



public void setSongs(Song[] songs) {
this.songs = songs;
}







public String disPlay() {
return "Title: " + getName() + ", Singer: " + getSinger()
+ "Recorded Year : " + getRecordedYear();
}




}

/***********/




public class TextMain {
MediaPlayer mp = new MediaPlayer();
Song [] songs = new Song[4];


Song s1 = new Song ("Hotline Bling", "Drake", 2015);
Song s2 = new Song ("What Do You Mean?", "Justin Bieber",2014);
Song s3 = new Song ("Watch Me", "Silento", 2011);
Song s4 = new Song ("679", "Fetty Wap ft. Remy Boyz",2009 );

Stack stc1 = new Stack(10);
Stack temp = new Stack(10);
/* stc.push(s1);
stc.push(s2);
stc.push(s2);
stc.push(s2);

*/

/*

for (int i = 0; i<10; i++) {

while (!stc.isEmpty()&&song.compareTo(indexOf(i))) {
s2.push(stc.pop());
s1.push();
}
while (!s2.isEmpty()) {

s1.push(s2.pop());
}
}
// print stack
while (!s1.isEmpty()) {
System.out.println(s1.peek()); ;
s2.push(s1.pop());
}
while (!s2.isEmpty()){
s1.push(s2.pop());


}
*/




}




Bu mesajda bahsedilenler: @Glitch
A
8 yıl (22495 mesaj)
Binbaşı




DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.