CD - { title = name; artist = singer; cost = price; tracks...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // CD.java Author: Lewis/Loftus // // Solution to Programming Project 12.1 // // Represents a compact disc. //******************************************************************** / import java.text.NumberFormat; i 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)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { title = name; artist = singer; cost = price; tracks = numTracks; } //-----------------------------------------------------------------// Returns a 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; } }...
View Full Document

Ask a homework question - tutors are online