recording.java

来自「《Java核心技术应用开发》电子工业出版社书籍源代码」· Java 代码 · 共 89 行

JAVA
89
字号
import java.util.*;

/**
 *  这个类代表音乐CD数据本身
 */
public abstract class Recording implements Comparable, java.io.Serializable {

	protected String title;

	protected double price;
	
	protected String category;
	
	protected String imageName;
	
	protected Duration duration;


	public Recording() {
		// default constructor
	}

	
	public Recording(String theTitle, double thePrice, 
					 String theCategory, String theImageName,
					 Duration theDuration) {
	
		title = theTitle;
		price = thePrice;
		category = theCategory;
		imageName = theImageName;
		duration = theDuration;
	}

	public Recording(String theTitle, double thePrice, 
					 String theCategory, String theImageName) {

		this(theTitle, thePrice, theCategory, theImageName, new Duration());	
	}


	public String getTitle() {
		return title;
	}
	
	public void setTitle(String theTitle) {
		title = theTitle;
	}


	public double getPrice() {
		return price;
	}
	
	public void setPrice(double thePrice) {
		price = thePrice;
	}


	public String getCategory() {
		return category;
	}
	
	public void setCategory(String theCategory) {
		category = theCategory;
	}


	public String getImageName() {
		return imageName;
	}
	
	public void setImageName(String theImageName) {
		imageName = theImageName;
	}
	
	
	public abstract Duration getDuration();	


	public int compareTo(Object object) {
	
		Recording recording = (Recording) object;
		String targetTitle = recording.getTitle();
		
		return title.compareTo(targetTitle);
	}
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?