Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

image text in transcribed 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

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions