Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I hope someone can help me with thefollowing. 1) Create a class CD with instance

ID: 3617884 • Letter: I

Question

I hope someone can help me with thefollowing.
1) Create a class CD with instancevariables title, artist, price, and number of tracks. Provide oneconstructor, get/set methods, and a toString method that returnsthe CD information as a String. 2) Create a CDCollection class withinstance variables count, total cost, and a CD array. The classshould have a constructor, get methods for the count and totalcost, and a toString method that returns the information for allCDs in the collection. The class will also have an addCD methodthat will take 4 arguments and create a CD object and place it inthe CD collection. Be sure to check the index when doing this sothat you don’t walk off of the array. Add the price to thetotal cost and count each CD added to thecollection. 3) Create a test programCDCollectionTest that adds AT LEAST 6 CDs to the CD collection. Theprogram outputs the number of CDs in the collection, the total costof all CDs, and the information about all CDs in the collection. Besure to clearly label the output and to comment your code. Use adialog box for output. I hope someone can help me with thefollowing.
1) Create a class CD with instancevariables title, artist, price, and number of tracks. Provide oneconstructor, get/set methods, and a toString method that returnsthe CD information as a String. 2) Create a CDCollection class withinstance variables count, total cost, and a CD array. The classshould have a constructor, get methods for the count and totalcost, and a toString method that returns the information for allCDs in the collection. The class will also have an addCD methodthat will take 4 arguments and create a CD object and place it inthe CD collection. Be sure to check the index when doing this sothat you don’t walk off of the array. Add the price to thetotal cost and count each CD added to thecollection. 3) Create a test programCDCollectionTest that adds AT LEAST 6 CDs to the CD collection. Theprogram outputs the number of CDs in the collection, the total costof all CDs, and the information about all CDs in the collection. Besure to clearly label the output and to comment your code. Use adialog box for output.

Explanation / Answer

classCDCollectionDriver.java public class CDCollectionDriver {     public static void main(String[] args) {         CDCollection cdc = newCDCollection(6);         cdc.addCD("Eye in theSky", "The Alan Parsons Project", 45, 11, 0);         cdc.addCD("dsfsdafdsaf","Hawkwind", 45, 11, 1);         cdc.addCD("SellingEngland by the Pound", "Genesis", 45, 11, 2);         cdc.addCD("third Album","some one", 45, 11, 3);         cdc.addCD("4th Album","another one", 45, 11, 4);         cdc.addCD("new album","no one", 45, 11, 5);        System.out.println(cdc);        System.out.println("Total Price : " + cdc.getTotalCost());        System.out.println("Total CDs   : " +cdc.getCount());     } }