Question: Please, does anyone know how to do this in java? 1. Create a list of songs using an array and after that you should be

Please, does anyone know how to do this in java?

1. Create a list of songs using an array and after that you should be able to sort the songs based on the different fields.

2. Design a class Song based on the UML diagram (at bottom). Song class contains a list of fields to describe a song. The duration field is a float number giving the length of the song in minutes. The Song constructor will create a song with the fields set to default values (String to , float to 0.0, int to 0). The setSong method will assignment the parameter values to the corresponding fields if the parameter value is a valid value. The toString method will return a String representation of the song information (including all the fields) in a formatted way.

3. Design a class SongList based on the UML diagram (at bottom). SongList contains a song array which can hold a MAX (a static final field to specify the length of the songList array to be created) number of songs. The size field is used to keep track of how many songs have been added into the songList so far. For the sorting method you can either modify the sorting algorithm we have discussed or you can implement your own.

4. Create a Project2 class with a static test method to test your song list. First you add a bunch of songs (at least 6) to your list, and then print out all the songs in your list. After that you can call different sort methods and print out the songs after each sort method call. Please also test your findSong() method to make sure it does return the right index of the song you are looking for.

UML Diagram:

Song

- title: String

- writer: String

- singer: String

- duration: float

- genre: String

- year:int

+Song() +setSong(String, String, String, float, Sting, int)

+getTitle(): String

+getWriter(): String

+getSinger(): String

+getDuration(): float

+getGenre(): String

+getYear(): int

+toString():String

UML Diagram:

SongList

- MAX: int

- songList: Song [ ]

- size: int

+SongList():

+addSong(Song): boolean

+findSong(String title): int

+swapSong(int, int):

+sortByWriter():

+sortByDuration():

+sortByGenre():

+sortByYear();

+toString(): String

+getSize(): int

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!