Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

What is the relation of physical mathematics with examples?

Answered: 1 week ago

Question

What are oxidation and reduction reactions? Explain with examples

Answered: 1 week ago