Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction to Song and Music Collection This project is meant to simulate a digital music collection. You will find the Song class has already been

Introduction to Song and Music Collection
This project is meant to simulate a digital music collection. You will find the Song class has
already been completed for you, so you should not add any code to it. You will be creating the
Music Collection class to represent a collection of Song objects as a Java Array List .
You should begin by creating a single field in the MusicCollection class of type ArrayList ,
and a default constructor that initializes this field to an empty ArrayList. Don't forget to add the
necessary import line to the top of the class!
Note: The purpose of this lab is to familiarize yourself with the pre-defined methods on Ar-
rayLists. After reading each task, you should then look through the ArrayList Documentation to
see which of them might be useful. If you make good use of the pre-defined methods, each of your
methods can be fairly simple!
Tasks
1. Writ an instance method addIfNew that takes a Song object as input, and that adds this
song to the ArrayList if it is not already contained in the list. If it is already in the list, the
method should do nothing.
2. Writ an instance method replaceSong that takes two songs oldSong and newSong as
input, and it replaces the oldSong in the list with the newSong (in the same location).
3. Writ an instance method containsArtist that takes an artist string as input, and that
returns true if there are any songs in the list by that artist. Otherwise, it should return
false .
1

 

 

 

4. Writ an instance method longSongs that takes a double minLength as input, and that
returns an ArrayList consisting of only those songs from the list whose length is at least
minLength .
Note: You may find it helpful also to write a toString method in your MusicCollection
class to aid in writing your Main test methods.
Submission
Once you have completed your method definitions in MusicCollection and your testing in Main ,
you should submit the two files MusicCollection.java and Main.java to the Lab 8 Part 1
assignment in Canvas.

 



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

Auditing Cases An Interactive Learning Approach

Authors: Mark S Beasley, Frank A. Buckless, Steven M. Glover, Douglas F Prawitt

7th Edition

0134421825, 9780134421827

More Books

Students also viewed these Programming questions

Question

What share capital is. AppendixLO1

Answered: 1 week ago

Question

How much is $102 after a decrease of 100%?

Answered: 1 week ago

Question

Calculate the missing value.

Answered: 1 week ago