Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Once you have coded and tested your SimpleMusicTrack class, you will need to write a SimplePlayList class that implements the PlayList interface given below. You

Once you have coded and tested your SimpleMusicTrack class, you will need to write a SimplePlayList class that implements the PlayList interface given below. You must download this file and import it into your MusicList source code folder before you can start to implement your own SimplePlayList class.

  • PlayList.javaimage text in transcribed

The SimplePlayList class stores music tracks in order - the first track added to the play list should be the first one removed from the play list. This data structure is known as a queue (or a first-in, first-out queue). As a hint, you can build your SimplePlayList class using an ArrayList of PlayListTrack objects to store the tracks (do not use an ArrayList of SimpleMusicTrack objects - it would work, but it may make your next Project assignment a bit more difficult). Again, as you write this class, write a test program to go along with it. Test each method as you write it, as we have discussed in class. You will need to start with a skeleton of your SimplePlayList code that has each method in the interface written as a "stub" as seen in the Closed Lab code you have modified (i.e. code that does nothing but return a default value to allow the class to compile), and then you should modify your stub code one method at a time, testing each change you make. You will not need to submit this test program, but using it will make your code development much, much easier.

The PlayList Management Program

Once you have written and tested a SimpleMusicTrack class and a SimplePlayList class, it is time to use them to write a program to manage playlists. This program will simulate the playing of songs from a play list. For the SimplePlayList, the songs are removed from the playlist as they are played, so you know that you're at the end of the list when your list is empty. You should name this program MusicList.java. Here is a sample transcript of the output of this program:

Enter database filename: playlist_input.txt Currently playing: No Song Playing Next track to play: Blue Suede Shoes / Elvis Presley [P]lay next track [A]dd a new track [Q]uit > p Currently playing: Blue Suede Shoes / Elvis Presley Next track to play: With A Little Help From My Friends / The Beatles [P]lay next track [A]dd a new track [Q]uit > p Currently playing: With A Little Help From My Friends / The Beatles Next track to play: Seven Nation Army / The White Stripes [P]lay next track [A]dd a new track [Q]uit > a Track name: Requiem For A Dying Song Artist name: Flogging Molly Album name: Float New track: Requiem For A Dying Song Artist: Flogging Molly Album: Float Are you sure you want to add this track [y]? y Currently playing: With A Little Help From My Friends / The Beatles Next track to play: Seven Nation Army / The White Stripes [P]lay next track [A]dd a new track [Q]uit > q Tracks remaining in play list ------------------------------------------------------------ 1 - Seven Nation Army / The White Stripes / Elephant 2 - Long Line Of Cars / Cake / Comfort Eagle 3 - Head Like A Hole / Nine Inch Nails / Pretty Hate Machine 4 - Requiem For A Dying Song / Flogging Molly / Float 
  1. Ask the user to enter the name of the file that contains the play list data in the format described above in Part I.
  2. Input the play list information from the file and store it in a SimplePlayList object (using SimpleMusicTrack objects). See below for the format of this file.
  3. Indicate what song is currently playing and what song is next in the play list. If there is no song currently playing (i.e. at the beginning right after the data file is loaded) the program should indicate this with a message No Song Playing. If the play list is empty and there is no next track, the program should indicate this with a message Play list is empty no more tracks.
  4. Present the user a menu of three options play the next song in the play list, add a new song to the play list, or quit.
  5. If the user chooses to play the next song, use the PlayList object to adjust the current track accordingly. Make sure your code does the right thing and gives an error message if the play list is empty and the user tries to play the next song.
  6. If the user chooses to add a new track, prompt the user for the names of the song, artist and album. Verify that the user actually wants to add the track and if they say yes to this prompt add the track to the play list appropriately.
  7. If the user chooses to quit, output a well-formatted report of the remaining songs in the play list, showing the name of the song, the artist and the album in the format indicated above. If the play list is empty, indicate this with the message No tracks remaining where the report data would normally be. When this report is finished the PlayList should be empty.

The file format that the play list manager program should read is a simple one. An input file for multiple tracks would use this format:

track 1 name artist 1 name album 1 name ... track n name artist n name album n name

The sample input file used in the transcript above looks like this:

Blue Suede Shoes Elvis Presley Elvis Presley: Legacy Edition With A Little Help From My Friends The Beatles Sgt. Pepper's Lonely Hearts Club Band Seven Nation Army The White Stripes Elephant Long Line Of Cars Cake Comfort Eagle Head Like A Hole Nine Inch Nails Pretty Hate Machine

PlayList.java

public interface PlayList {

/**

* Returns the current track in the play list and removes it from the play

* list, advancing to the next track. If the play list is empty, the

* behavior of this method is undefined, so the caller is required to check

* to see if the play list is empty BEFORE calling this method.

*

* @return the current track in the play list

*/

public PlayListTrack getTrack();

/**

* Returns the current track in the play list without removing it. If the

* play list is empty the behavior of this method is undefined so the caller

* is required to check to see if the play list is empty BEFORE calling this

* method.

*

* @return the current track in the play list

*/

public PlayListTrack peekAtTrack();

/**

* Appends another track to the end of the play list

*

* @param track

* track to be appened to the end of the list

*/

public void addTrack(PlayListTrack track);

/**

* @return true if the list is empty, false otherwise

*/

public boolean isEmpty();

}

SimpleMusicTrack.java

public class SimpleMusicTrack implements PlayListTrack {

// You will need to set up your own private variables here.

@Override

public String getName() {

// TODO Auto-generated method stub

return null;

}

@Override

public void setName(String name) {

// TODO Auto-generated method stub

}

@Override

public String getArtist() {

// TODO Auto-generated method stub

return null;

}

@Override

public void setArtist(String artist) {

// TODO Auto-generated method stub

}

@Override

public String getAlbum() {

// TODO Auto-generated method stub

return null;

}

@Override

public void setAlbum(String album) {

// TODO Auto-generated method stub

}

@Override

public boolean equals(Object obj) {

// TODO Auto-generated method stub

return false;

}

@Override

public String toString() {

// TODO Auto-generated method stub

return null;

}

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

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

8. Explain how to price managerial and professional jobs.pg 87

Answered: 1 week ago