//******************************************************************** // CD.java Author: Lewis and Loftus // // Represents a compact disc. //******************************************************************** import java.text.NumberFormat; public class CD { private String title, artist; private double value; private int tracks; //----------------------------------------------------------------- // Creates a new CD with the specified information. //----------------------------------------------------------------- public CD (String theTitle, String theArtist, double theValue, int theTracks) { title = theTitle; artist = theArtist; value = theValue; tracks = theTracks; } //----------------------------------------------------------------- // Returns a description of this CD. //----------------------------------------------------------------- public String toString() { NumberFormat fmt = NumberFormat.getCurrencyInstance(); String description; description = fmt.format(value) + "\t" + tracks + "\t"; description += title + "\t" + artist; return description; } }