Question: Create a class CD with the following: - Instance variables title, artist, price, and number of tracks - One constructor with four parameters. Be sure

Create a class CD with the following: - Instance variables title, artist, price, and number of tracks - One constructor with four parameters. Be sure to validate the price (no negative value) and the number of tracks (not less than one). Use default values 0.00 for an invalid price and 1 for an invalid number of tracks. - Get/set methods for all instance variables. Be sure to validate in the setPrice and setNumberOfTracks methods use the default values above. - A toString method that returns the CD information as a String. Be sure to format the price as currency. - A UML class diagram for the CD class.

Create a test program CDTest with an array of type CD that holds 6 CD objects. Create 6 CDs and place them in the array of CDs. Use real data for the CDs but NOT my example data. The program must display the information about each CD in the array. Do this by calling the toString method on each CD object in the array (use a loop). Be sure to clearly label the output and to comment your code. Use a dialog box for output.

EXAMPLE OUTPUT:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!