Şimdi Ara

Java stack şarkı listesi yardımı

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir (1 Mobil) - 1 Masaüstü1 Mobil
5 sn
8
Cevap
0
Favori
268
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • 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



  • upppp
  • uppppp
  • Yokmu yardım edebilecekkk
  • 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ı >
  • Glitch G kullanıcısına yanıt
    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());


    }
    */




    }




  • Yapay Zeka’dan İlgili Konular
    Daha Fazla Göster
    
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.