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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started