📄 cd.java
字号:
//********************************************************************
// CD.java Author: Lewis/Loftus
//
// Represents a compact disc.
//********************************************************************
import java.text.NumberFormat;
public class CD
{
private String title, artist;
private double cost;
private int tracks;
//-----------------------------------------------------------------
// Creates a new CD with the specified information.
//-----------------------------------------------------------------
public CD (String name, String singer, double price, int numTracks)
{
title = name;
artist = singer;
cost = price;
tracks = numTracks;
}
//-----------------------------------------------------------------
// Returns a string description of this CD.
//-----------------------------------------------------------------
public String toString()
{
NumberFormat fmt = NumberFormat.getCurrencyInstance();
String description;
description = fmt.format(cost) + "\t" + tracks + "\t";
description += title + "\t" + artist;
return description;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -