⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 musicrecording.java

📁 《Java核心技术应用开发》电子工业出版社书籍源代码
💻 JAVA
字号:
/**
 *  这个类代表音乐CD数据本身
 */
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 + -