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
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());
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