//******************************************************************** // CD.java Author: Lewis and Loftus // // Rappresenta l'oggetto CD. //******************************************************************** import java.text.NumberFormat; public class CD { private String title, artist; private double value; private int tracks; //----------------------------------------------------------------- // Crea un nuovo CD con le informazioni specificate. //----------------------------------------------------------------- public CD (String titolo, String artista, double valore, int tracce) { title = titolo; artist = artista; value = valore; tracks = tracce; } //----------------------------------------------------------------- // Riporta la descrizione del singolo CD. //----------------------------------------------------------------- public String toString() { NumberFormat fmt = NumberFormat.getCurrencyInstance(); String descrizione; descrizione = fmt.format(value) + "\t\t" + tracks + "\t"; descrizione += title + "\t\t" + artist; return descrizione; } }