java - Playlist class music database -


i'm writing simple music database , atm i'm trying create playlist class let user organise music (4 tracks entered database class) playlist of 3 songs.

after user selects song put playlist, method meant search closest free slot in newplaylist , place song variables (artist, name, duration & filesize) inside.

at moment receiving this;


entering playlist tool...

 hello, welcome playlist builder! please select track add new playlist database below(using keys 1-4) slot 1:trees:breeze:2.34:128 1 error: there no free space in database slot : song@3a1ec6 slot b : song@1ba6076 slot c : song@112e7f7      menu 0 exit 1 import track 2 show 3 build playlist(requires atleast 1 track in database) 

am right in guessing being returned reference location of variables , not variables themselves?

the code playlist.class is;

public class playlist {      song songdataplay = new song();     static userinterface ui = new userinterface();      static song playlisttracka = new song();     static song playlisttrackb = new song();     static song playlisttrackc = new song();      private int max_time;     private double totalsize;     private double totaltime;      string playlistclassartist, playlistclassname;     double playlistclassduration;     int playlistclassfilesize;      static string playlistartist;     static string playlistname;     static double playlistduration;     static int playlistfilesize;     static song newplaysong;     static song newsong;      static song carryfromuserintoplaylist = ui.newplaylistsongin;      public void playlistobject(song a, song b, song c) {         this.playlisttracka = a;         this.playlisttrackb = b;         this.playlisttrackc = c;     }       public static void playlistallocation() {         newsong = ui.newplaylistsongin;         playlist plu = new playlist();         songdatabase sd = new songdatabase();         song newsong = carryfromuserintoplaylist;           if (playlisttracka.songfilesize == 0) {              setsonga(newplaysong);              system.out.println("slot : " + playlisttracka);             system.out.println("slot b : " + playlisttrackb);             system.out.println("slot c : " + playlisttrackc);              newplaysong = newsong;          } else if (playlisttrackb.songfilesize == 0) {              setsongb(newplaysong);              system.out.println("slot : " + playlisttracka);             system.out.println("slot b : " + playlisttrackb);             system.out.println("slot c : " + playlisttrackc);              newplaysong = newsong;          } else if (playlisttrackc.songfilesize == 0) {              setsongc(newplaysong);              system.out.println("slot : " + playlisttracka);             system.out.println("slot b : " + playlisttrackb);             system.out.println("slot c : " + playlisttrackc);              newplaysong = newsong;          } else {              system.out.println("error: there no free space in database");              system.out.println("slot : " + playlisttracka);             system.out.println("slot b : " + playlisttrackb);             system.out.println("slot c : " + playlisttrackc);          }     }      public static void setsonga(song newsong) {          playlisttracka = newplaysong;          playlisttracka.songartist = newplaysong.songartist;         playlisttracka.songname = newplaysong.songname;         playlisttracka.songduration = newplaysong.songduration;         playlisttracka.songfilesize = newplaysong.songfilesize;      }      public song getsonga() {          return (playlisttracka);     }       public static void setsongb(song newsong) {          playlisttrackb = newplaysong;          playlisttrackb.songartist = newplaysong.songartist;         playlisttrackb.songname = newplaysong.songname;         playlisttrackb.songduration = newplaysong.songduration;         playlisttrackb.songfilesize = newplaysong.songfilesize;      }       public song getsongb() {          return (playlisttrackb);     }       public static void setsongc(song newsongc) {          playlisttrackc = newplaysong;          playlisttrackc.songartist = newplaysong.songartist;         playlisttrackc.songname = newplaysong.songname;         playlisttrackc.songduration = newplaysong.songduration;         playlisttrackc.songfilesize = newplaysong.songfilesize;      }      public song getsongc() {          return (playlisttrackc);      }      public string returnplaylist() {           if (playlisttracka.songfilesize == 0 && playlisttrackb.songfilesize == 0 && playlisttrackc.songfilesize == 0) {             return ("error ; no new playlists have been added.");         } else if (playlisttrackb.songfilesize == 0 && playlisttrackc.songfilesize == 0) {             return ("you have imported:" + newplaysong.songname + " " + newplaysong.songartist + " slot in new playlist");         } else if (newplaysong.songfilesize == 0) {             return ("you have imported:" + newplaysong.songname + " " + newplaysong.songartist + "  slot b in new playlist");         } else {             return ("you have imported:" + newplaysong.songname + " " + newplaysong.songartist + "  slot c in new playlist");         }      }   } 

any great thanks,

system.out.println("slot : "+playlisttracka); calls tostring() method of song (which derived object). default prints hash code of object.

you should better print playlisttracka.songname if understand code right.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -