Question
You are given a class called Record, which defines an audio (pre-CD or MP3) Record. If you need to, you can add methods to this class.

You are to write a class called Jukebox, which holds a number of Records. Jukebox can use either an ArrayList or a Vector to store its data (Records). This will be referred to as AL or V from here on.

Your Jukebox class should implement JukeInterface, which is also in this Minilab’s folder. It will tell what methods must be implemented (and the comments describe how the methods should work).

You can write Jukebox in either one of two ways:

1) Jukebox can be a subclass of AL or V (using “implements”). This makes all of the AL or V methods automatically inherited by Jukebox. So in the Jukebox code, you can access the .indexOf method (for example) by calling indexOf or this.indexOf. This is because it is the Jukebox’s own method.   

The disadvantage of this is that outside programs (like the tester) can call Jukebox’s methods and also call the AL or V methods.

2) Jukebox can be a class that has an AL or V as part of its data. In the Polymorphism Minilab, this is how Course was implemented – it had an Array as part of its data.   If you do it this way, you should

- declare the AL or V as data and then
- create it (with a “new” statement) in the constructor.   

The advantage is that outside programs (like the tester) can now only “see” the Jukebox’s methods.

In addition, you have 2 other requirements:
1) You should use Generics to define your AL or V. In your program, it will only hold Records.
2) You should not traverse the AL or V to try to “do things yourself.” You can look up built-in AL or V methods which will do everything you need. NOTE: In order for some built-in AL or V methods to work correctly, you will have to add a specific method to Record (as described in class).
Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references.
Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

//This class describes a (pre-CD) record

public class Record implements Comparable<Record>
{
    //data
    private String title;
    private String artist;

    //constructor
    public Record(String theTitle, String theArtist)
    {
            this.title = theTitle;
            this.artist = theArtist;
    }

    /**
    * this let us use comparing ability with vector in jukebox class
    * @param o
    * @return
    */
    @Override
    public int compareTo(Record o) {
       if (o == null) {
            return 1;
       }
       if (title.equals(o.title)) {
            return artist.compareTo(o.artist);
       }
       return title.compareTo(title);
    }
This is only a preview of the solution.
Please use the purchase button to see the entire solution.
By purchasing this solution you'll be able to access the following files:
Solution.zip
Purchase Solution
$30.00
Google Pay
Amazon
Paypal
Mastercard
Visacard
Discover
Amex
View Available Computer Science Tutors 645 tutors matched
Ionut
(ionut)
Master of Computer Science
Hi! MSc Applied Informatics & Computer Science Engineer. Practical experience in many CS & IT branches.Research work & homework
5/5 (6,808+ sessions)
1 hour avg response
$15-$50 hourly rate
Pranay
(math1983)
Doctor of Philosophy (PhD)
Ph.D. in mathematics and working as an Assistant Professor in University. I can provide help in mathematics, statistics and allied areas.
4.6/5 (6,702+ sessions)
1 hour avg response
$40-$50 hourly rate
Leo
(Leo)
Doctor of Philosophy (PhD)
Hi! I have been a professor in New York and taught in a math department and in an applied math department.
4.9/5 (6,469+ sessions)
2 hours avg response

Similar Homework Solutions