?? musicrecording.java
字號:
/**
* 這個類代表音樂CD數(shù)據(jù)本身
*/
public class MusicRecording extends Recording implements java.io.Serializable {
protected String artist;
protected Track trackList[];
public MusicRecording(String theArtist, Track[] theTrackList,
String theTitle, double thePrice,
String theCategory, String theImageName,
Duration theDuration) {
super(theTitle, thePrice, theCategory, theImageName, theDuration);
artist = theArtist;
trackList = theTrackList;
}
public MusicRecording(String theArtist, Track[] theTrackList,
String theTitle, double thePrice,
String theCategory, String theImageName) {
super(theTitle, thePrice, theCategory, theImageName);
artist = theArtist;
trackList = theTrackList;
}
public String getArtist() {
return artist;
}
public Track[] getTrackList() {
return trackList;
}
public Duration getDuration() {
Track tempTrack;
Duration tempDuration;
int total = 0;
for (int i=0; i < trackList.length; i++) {
tempTrack = trackList[i];
tempDuration = tempTrack.getDuration();
total += tempDuration.getTotalSeconds();
}
return new Duration(total);
}
public String toString() {
return artist + " - " + title;
}
public int compareTo(Object object) {
MusicRecording recording = (MusicRecording) object;
String targetArtist = recording.getArtist();
return artist.compareTo(targetArtist);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -