Question: Objective: Create a VinylCollection class that manages a vinyl record collection using a bag data structure. This class will support adding multiple records, removing records

Objective:
Create a VinylCollection class that manages a vinyl record collection using a bag data
structure. This class will support adding multiple records, removing records in different ways,
and analyzing the collection to find the artist with the most records.
Your VinylCollection will hold VinylRecord objects. Use the provided VinylRecord.java
class, which includes attributes such as album title, artist, and genre.
Requirements:
1. Vinyl Collection Operations: Your VinylCollection should support the following
operations:
o Add a new record to the collection.
o Add multiple copies of a given record (e.g., add 3 copies of "Abbey Road").
o Remove a record randomly from the collection (as if pulling one off the shelf at
random).
o Remove a specific record by searching for it in the collection (as if selecting a
specific album to play).
o Display the entire collection, listing each records album title, artist, and genre.
At the end, display the total number of records in the collection.
o Determine which artist has the most records in the collection.
2. Driver Program: Write a driver program to test your VinylCollection
implementation. Your driver should:
o Create several VinylRecord instances.
o Add records to the collection.
o Add multiple copies of some records to the collection.
o Remove records both randomly and specifically.
o Display the collection and confirm that the total number of records is correctly
displayed.
o Test the method that determines which artist has the most records and confirm it
works as expected.
3. Coding Principles: Follow sound coding practices to ensure that your implementation is
generalized, reusable, and well-documented:
o Your VinylCollection class should be able to use any bag implementation, and
all methods should work regardless of which bag implementation is used.
o Avoid re-implementing existing bag operations. Use them within your vinyl
collection class.
o Document your code with header comments for each method and in-line
comments as needed to explain the logic and functionality.
vinylrecord.java provided:
public class VinylRecord {
private String albumTitle;
private String artist;
private String genre;
// Constructor
public VinylRecord(String albumTitle, String artist, String genre){
this.albumTitle = albumTitle;
this.artist = artist;
this.genre = genre;
}
// Getters
public String getAlbumTitle(){
return albumTitle;
}
public String getArtist(){
return artist;
}
public String getGenre(){
return genre;
}
// Setters
public void setAlbumTitle(String albumTitle){
this.albumTitle = albumTitle;
}
public void setArtist(String artist){
this.artist = artist;
}
public void setGenre(String genre){
this.genre = genre;
}
// Override equals() to compare VinylRecord objects based on album title, artist, and genre
@Override
public boolean equals(Object obj){
if (this == obj){
return true;
}
if (obj == null || getClass()!= obj.getClass()){
return false;
}
VinylRecord that =(VinylRecord) obj;
return albumTitle.equals(that.albumTitle) &&
artist.equals(that.artist) &&
genre.equals(that.genre);
}
// Override toString() for easy display of a VinylRecord's information
@Override
public String toString(){
return "Album: "+ albumTitle +", Artist: "+ artist +", Genre: "+ genre;
}
}

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 Programming Questions!