0
간단한 음악 데이터베이스와 ATM을 쓰고 있습니다. 이전에 데이터베이스 클래스에 입력 한 4 곡의 음악을 3 곡의 재생 목록으로 구성 할 수있는 재생 목록 클래스를 만들려고합니다. .재생 목록 클래스 음악 데이터베이스
사용자가 재생 목록에 넣을 노래를 선택하면 메서드는 newplaylist에서 가장 가까운 빈 슬롯을 검색하고 Song 변수 (아티스트, 이름, 기간, & 파일 크기)를 안에 넣습니다.
나는 이것을 받고 있습니다. 재생 목록 도구 입력
...
Hello, welcome to the playlist builder! Please select a track to add to the new playlist from the database below(using keys 1-4) Slot 1:Trees:Breeze:2.34:128 1 Error: there is no free space in the database Slot A : [email protected] Slot B : [email protected] Slot C : [email protected] MENU 0 EXIT 1 IMPORT TRACK 2 SHOW ALL 3 Build a playlist(requires atleast 1 track in database)
내가 옳은 일을 반환되는 것은 변수가 아닌 변수 자신의 위치에 대한 참조입니다 추측에 있습니까?
Playlist.class의 코드는 다음과 같습니다.
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 A : " + 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 A : " + 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 A : " + playlisttrackA);
System.out.println("Slot B : " + playlisttrackB);
System.out.println("Slot C : " + playlisttrackC);
newplaySong = newSong;
} else {
System.out.println("Error: there is no free space in the database");
System.out.println("Slot A : " + 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 + " By " + newplaySong.songartist + " to slot A in the new playlist");
} else if (newplaySong.songfileSize == 0) {
return ("You have imported:" + newplaySong.songname + " By " + newplaySong.songartist + " to slot B in the new playlist");
} else {
return ("You have imported:" + newplaySong.songname + " By " + newplaySong.songartist + " to slot C in the new playlist");
}
}
}
어떤 도움도 큰 감사 것,
감사 인사로 변경해야합니다. 내 재생 목록이 가득 찬 이유에 대한 아이디어도 있습니까? – Jerry
디버거를 사용하여 쉽게이 문제를 해결할 수 있습니다 ;-) 어떻게 든 모든 'songfileSize'는'! = 0'입니다. 나는 당신이 노래를 설정하는 곳 ('playlistObject'는 어디에서 호출 되었는가?)을 보지 못했고 NullPointerException (throw되지 않음)을 기대할 것이므로 전혀 모른다. – Kai