Question: Question 13 (30 marks). Consider two (2) classes: CD and Track. These classes hold information about music CDs in a collection and the tracks (songs)

 Question 13 (30 marks). Consider two (2) classes: CD and Track.

Question 13 (30 marks). Consider two (2) classes: CD and Track. These classes hold information about music CDs in a collection and the tracks (songs) on each CD. a) The Track class has the following instance variables: trackID (int) - eg. 10 name (String) - eg. "The Long and Winding Road" seconds (int) - eg. 218 (This is the length of the track in seconds) The class should have mutator (setter) methods and accessor (getter) methods for all instance variables. Write in Java the class Track. The instance variables are private and the methods are public. b) Now write in Java the CD class. The CD class has the following instance variables: IDNumber (String) - eg: "BT003" artist (String) - eg: "The Beatles" name (String) - eg: "Let it Be" tracks (an array of tracks with a maximum size of 20, representing the tracks on the CD) The methods are: setIDNumber (String s) (set the variable IDNumber) getIDNumber() (return the value in the variable IDNumber) setName(String s) (set the variable name) getName() (return the value in the variable name) averageTime() (return the average length of tracks in seconds.) addTrack() (add a Track to the array in the next vacant position. The values of the Track instance variables will be passed as parameters to this method.) The instance variables are private and the methods are public. The class needs to have one constructor which will set the instance variables with values passed as parameters. It will also instantiate the tracks array but will add no tracks

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!