track.java
来自「《Java核心技术应用开发》电子工业出版社书籍源代码」· Java 代码 · 共 54 行
JAVA
54 行
/**
* 这个类代表歌曲数据本身
*/
public class Track implements java.io.Serializable {
protected String title;
protected Duration duration;
public Track() {
title = "empty";
duration = new Duration();
}
public Track(String aTitle, Duration aDuration) {
title = aTitle;
duration = aDuration;
}
public String getTitle() {
return title;
}
public void setTitle(String aTitle) {
title = aTitle;
}
public Duration getDuration() {
return duration;
}
public void setDuration(Duration aDuration) {
duration = aDuration;
}
public String toString() {
int totalSeconds = duration.getTotalSeconds();
int min = totalSeconds / 60;
int secs = totalSeconds % 60;
String secsStr = "";
if (secs < 10)
{
secsStr = "0";
}
secsStr += Integer.toString(secs);
return title + ", " + min + ":" + secsStr;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?