Part I - The SimpleMusicTrack class For this assignment you must design a class
ID: 3873166 • Letter: P
Question
Part I - The SimpleMusicTrack class
For this assignment you must design a class named SimpleMusicTrack. This class must implement the PlayListTrackinterface given below. You must download this file and import it into your Project03 source code folder before you can start to implement your own SimpleMusicTrack class.
PlayListTrack.java
It is up to you how to represent the member variables of your SimpleMusicTrack class, but it must implement all of the methods given in the MusicTrack interface. Note in particular that it must implement thegetNextTrack(Scanner in) method that reads a single entry from a Scanner object (used with the input datafile).
In addition, your SimpleMusicTrack class must implement the following methods not provided in the interface, but are inherited from the Object class:
equals(Object obj) – should return a true value if the name, artist and album in the two tracks are the same. Otherwise should return a false value.
toString() – should return a string that contains the artist name followed by the track name with a single slash between them. The whole String should be surrounded by single quote marks (i.e. ‘Elvis Presley / Jailhouse Rock’).
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 SimpleMusicTrack 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.
PlayListTrack Interface
The file format that the SimpleMusicTrack class should read is a simple one. An input file for multiple tracks would use this format:
A sample input file might look like this:
The getNextTrack method should take a Scanner that has already opened an input file as a parameter. It should read the next three lines of the file into their appropriate member variables for the object. If the track is successfully loaded (i.e. all values are there and read from the file) it should return true. If there is a failure (for example, the code reads two lines and then the file ends without having a third line), then the method should return false. The method should NOT throw an exception error in the case of an error - it should catch the exception and return a value of false instead.
Part II - The SimplePlayList Class
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 Project03 source code folder before you can start to implement your own SimplePlayList class.
PlayList.java
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.
PlayList interface
Part III - 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 Project03.java.
Here is a sample transcript of the output of this program:
Ask the user to enter the name of the file that contains the play list data in the format described above in Part I.
Input the play list information from the file and store it in a SimplePlayList object (using SimpleMusicTrack objects).
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”.
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.
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.
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.
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.
Extra Credit
For up to 2 points of extra credit on this project, implement two other PlayList data types. The first should be named PlayListStack and it should use a Stack as the underlying model for how the PlayList operates -- meaning that it should add and remove tracks in a Last In/First Out manner, and it should use a Stack as a private member variable to store tracks. The second should be named PlayListQueue and it should use a Queue as the underlying model for how the PlayList operates -- meaning that it should add and remove tracks in a First In/First Out manner, and it should use a Queue (LinkedList) as a private member variable to store tracks. Modify your Project03.java program to prompt the user for what kind of PlayList they want to use and make sure your code works appropriately for any version they choose. Your prompt can be as simple as asking them to enter a letter - 's' for Stack, 'q' for Queue and 'p' for a SimplePlayList type.
Explanation / Answer
Project03.java
--------------------------------------------------------------
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
public class Project03 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("What PlayList do you want? 's'--Stack, 'q'--Queue,'p'--Simple");
Scanner in = new Scanner (System.in);
String type = in.nextLine();
if(type.equals("s")){
stackType();
}
if(type.equals("q")){
queueType();
}
if(type.equals("p")){
simpleType();
}
}
public static void simpleType(){
ArrayList <PlayListTrack> trackInfo = new ArrayList<PlayListTrack>();
System.out.print("Enter file name: ");
Scanner in = new Scanner (System.in);
String fname = in.nextLine();
trackInfo = loadTrack(fname);
userMenu(trackInfo);
}
public static void stackType(){
Stack<PlayListTrack> trackInfo = new Stack<PlayListTrack>();
System.out.print("Enter file name: ");
Scanner in = new Scanner (System.in);
String fname = in.nextLine();
trackInfo = loadStack(fname);
userMenu1(trackInfo);
}
public static void queueType(){
Queue<PlayListTrack> trackInfo = new LinkedList<PlayListTrack>();
System.out.print("Enter file name: ");
Scanner in = new Scanner (System.in);
String fname = in.nextLine();
trackInfo = loadQueue(fname);
userMenu2(trackInfo);
}
public static ArrayList<PlayListTrack> loadTrack (String fname){
ArrayList <PlayListTrack> track = new ArrayList<PlayListTrack>();
try{
Scanner infile = new Scanner (new File (fname));
while(infile.hasNext()){
String name = infile.nextLine();
String artist = infile.nextLine();
String album = infile.nextLine();
SimpleMusicTrack s1 = new SimpleMusicTrack(name,artist,album);
track.add(s1);
}
infile.close();
return track;
}
catch(IOException e){
System.out.print("Error!");
}
return null;
}
public static Stack<PlayListTrack> loadStack (String fname){
try{
Stack <PlayListTrack> track = new Stack<PlayListTrack>();
Scanner infile = new Scanner (new File (fname));
while(infile.hasNext()){
String name = infile.nextLine();
String artist = infile.nextLine();
String album = infile.nextLine();
SimpleMusicTrack s1 = new SimpleMusicTrack(name,artist,album);
track.push(s1);
}
infile.close();
return track;
}
catch(IOException e){
System.out.print("Error!");
}
return null;
}
public static Queue<PlayListTrack> loadQueue (String fname){
try{
Queue <PlayListTrack> track = new LinkedList<PlayListTrack>();
Scanner infile = new Scanner (new File (fname));
while(infile.hasNext()){
String name = infile.nextLine();
String artist = infile.nextLine();
String album = infile.nextLine();
SimpleMusicTrack s1 = new SimpleMusicTrack(name,artist,album);
track.add(s1);
}
infile.close();
return track;
}
catch(IOException e){
System.out.print("Error!");
}
return null;
}
public static void userMenu (ArrayList<PlayListTrack> track){
SimplePlayList s1 = new SimplePlayList(track);
if(track.size()==0){
System.out.println("Play list is empty Ð no more tracks");
}
else{
System.out.println();
System.out.println("Currently playing: No Song Playing");
System.out.println("Next track to play: "+ track.get(0).getName()+" / "+track.get(0).getArtist());
System.out.println("[P]lay next track");
System.out.println("[A]dd a new track");
System.out.println("[Q]uit");
Scanner in = new Scanner (System.in);
String input = in.nextLine();
if(input.equals("p")){
outputNext(s1,track);
}
if(input.equals("a")){
outputAdd(s1,track);
}
if(input.equals("q")){
outputQuit(s1,track);
}
}
}
public static void userMenu1 (Stack<PlayListTrack> track){
PlayListStack playList1 = new PlayListStack(track);
if(track.size()==0){
System.out.println("Play list is empty Ð no more tracks");
}
else{
System.out.println();
System.out.println("Currently playing: No Song Playing");
System.out.println("Next track to play: "+ track.peek().getName()+" / "+track.peek().getArtist());
System.out.println("[P]lay next track");
System.out.println("[A]dd a new track");
System.out.println("[Q]uit");
Scanner in = new Scanner (System.in);
String input = in.nextLine();
if(input.equals("p")){
outputNext1(playList1,track);
}
if(input.equals("a")){
outputAdd1(playList1,track);
}
if(input.equals("q")){
outputQuit1(playList1,track);
}
}
}
public static void userMenu2 (Queue<PlayListTrack> track){
PlayListQueue playList1 = new PlayListQueue(track);
if(track.size()==0){
System.out.println("Play list is empty Ð no more tracks");
}
else{
System.out.println();
System.out.println("Currently playing: No Song Playing");
System.out.println("Next track to play: "+ track.peek().getName()+" / "+track.peek().getArtist() );
System.out.println("[P]lay next track");
System.out.println("[A]dd a new track");
System.out.println("[Q]uit");
Scanner in = new Scanner (System.in);
String input = in.nextLine();
if(input.equals("p")){
outputNext2(playList1,track);
}
if(input.equals("a")){
outputAdd2(playList1,track);
}
if(input.equals("q")){
outputQuit2(playList1,track);
}
}
}
public static void outputCurrent(SimplePlayList list,ArrayList<PlayListTrack> track){
System.out.println();
System.out.println("Currently playing: "+track.get(0).getName()+" / "+track.get(0).getArtist());
System.out.println("Next track to play: "+track.get(1).getName()+" / "+track.get(1).getArtist());
System.out.println("[P]lay next track");
System.out.println("[A]dd a new track");
System.out.println("[Q]uit");
Scanner in = new Scanner (System.in);
String input = in.nextLine();
if(input.equals("p")){
outputNext(list,track);
}
if (input.equals("a")){
outputAdd(list,track);
}
if(input.equals("q")){
outputQuit(list,track);
}
}
public static void outputCurrent1(PlayListStack list,Stack<PlayListTrack> track){
Stack<PlayListTrack> newTrack = new Stack<PlayListTrack>();
for(int i=0;i<track.size();i++){
newTrack.addAll(track);
}
System.out.println();
System.out.println("Currently playing: "+track.peek().getName()+" / "+ track.peek().getArtist());
newTrack.pop();
System.out.println("Next track to play: "+newTrack.peek().getName()+" / "+newTrack.peek().getArtist());
System.out.println("[P]lay next track");
System.out.println("[A]dd a new track");
System.out.println("[Q]uit");
Scanner in = new Scanner (System.in);
String input = in.nextLine();
if(input.equals("p")){
outputNext1(list,track);
}
if (input.equals("a")){
outputAdd1(list,track);
}
if(input.equals("q")){
outputQuit1(list,track);
}
}
public static void outputCurrent2(PlayListQueue list,Queue<PlayListTrack> track){
Queue<PlayListTrack> newTrack = new LinkedList<PlayListTrack>(track);
System.out.println();
System.out.println("Currently playing: "+track.peek().getName()+" / "+track.peek().getArtist());
newTrack.remove();
System.out.println("Next track to play: "+newTrack.peek().getName()+" / "+newTrack.peek().getArtist());
System.out.println("[P]lay next track");
System.out.println("[A]dd a new track");
System.out.println("[Q]uit");
Scanner in = new Scanner (System.in);
String input = in.nextLine();
if(input.equals("p")){
outputNext2(list,track);
}
if (input.equals("a")){
outputAdd2(list,track);
}
if(input.equals("q")){
outputQuit2(list,track);
}
}
public static void outputNext(SimplePlayList list,ArrayList<PlayListTrack> track){
ArrayList<PlayListTrack> newTrack = new ArrayList<PlayListTrack>();
for(int i=0;i<track.size();i++){
newTrack.add((track.get(i)));
}
System.out.println();
System.out.println("Currently playing: "+track.get(0).getName()+" / "+track.get(0).getArtist());
list.getNextTrack();
System.out.println("Next track to play: "+list.peekAtNextTrack().getName()+" / "+list.peekAtNextTrack().getArtist());
System.out.println("[P]lay next track");
System.out.println("[A]dd a new track");
System.out.println("[Q]uit");
Scanner in = new Scanner (System.in);
String input = in.nextLine();
if(input.equals("p")){
outputNext(list,track);
}
if (input.equals("a")){
outputAdd(list,newTrack);
}
if(input.equals("q")){
outputQuit(list,newTrack);
}
}
public static void outputAdd(SimplePlayList list1,ArrayList<PlayListTrack> track1){
System.out.println();
System.out.println("Track name: Requiem For A Dying Song");
System.out.println("Artist name: Flogging Molly");
System.out.println("Album name: Float");
System.out.println();
System.out.println("New track: Requiem For A Dying Song");
System.out.println("Artist: Flogging Molly");
System.out.println("Album: Float");
System.out.print("Are you sure you want to add this track [y/n]?");
SimpleMusicTrack track = new SimpleMusicTrack("Requiem For A Dying Song","Flogging Molly","Float");
Scanner in = new Scanner (System.in);
String choose = in.nextLine();
if (choose.equals("y")){
list1.addTrack(track);
track1.add(track1.size(), track);
outputCurrent(list1,track1);
}
if (choose.equals("n")){
outputCurrent(list1,track1);
}
}
public static void outputQuit(SimplePlayList list2,ArrayList<PlayListTrack> track2){
System.out.println();
System.out.println("Tracks remaining in play list");
System.out.println("------------------------------------------------------------");
int count = track2.size();
if(list2.isEmpty()){
System.out.println("No tracks remaining");
}
else{
for (int num = 1; num < count;num++){
track2.remove(0);
System.out.println(num+" - "+track2.get(0).getName()+" / "+track2.get(0).getArtist()+" / "+track2.get(0).getAlbum());
}
}
}
public static void outputNext1(PlayListStack list,Stack<PlayListTrack> track){
Stack<PlayListTrack> newTrack = new Stack<PlayListTrack>();
for(int i=0;i<track.size();i++){
newTrack.addAll(track);
}
System.out.println();
System.out.println("Currently playing: "+list.peekAtNextTrack().getName()+" / "+list.peekAtNextTrack().getArtist());
list.getNextTrack();
System.out.println("Next track to play: "+list.peekAtNextTrack().getName()+" / "+list.peekAtNextTrack().getArtist());
System.out.println("[P]lay next track");
System.out.println("[A]dd a new track");
System.out.println("[Q]uit");
Scanner in = new Scanner (System.in);
String input = in.nextLine();
if(input.equals("p")){
outputNext1(list,track);
}
if (input.equals("a")){
outputAdd1(list,newTrack);
}
if(input.equals("q")){
outputQuit1(list,newTrack);
}
}
public static void outputAdd1(PlayListStack list1,Stack<PlayListTrack> track1){
System.out.println();
System.out.println("Track name: Requiem For A Dying Song");
System.out.println("Artist name: Flogging Molly");
System.out.println("Album name: Float");
System.out.println();
System.out.println("New track: Requiem For A Dying Song");
System.out.println("Artist: Flogging Molly");
System.out.println("Album: Float");
System.out.print("Are you sure you want to add this track [y/n]?");
SimpleMusicTrack track = new SimpleMusicTrack("Requiem For A Dying Song","Flogging Molly","Float");
Scanner in = new Scanner (System.in);
String choose = in.nextLine();
if (choose.equals("y")){
list1.addTrack(track);
track1.push(track);
outputCurrent1(list1,track1);
}
if (choose.equals("n")){
outputCurrent1(list1,track1);
}
}
public static void outputQuit1(PlayListStack list2,Stack<PlayListTrack> track2){
System.out.println();
System.out.println("Tracks remaining in play list");
System.out.println("------------------------------------------------------------");
if(list2.isEmpty()){
System.out.println("No tracks remaining");
}
else{
for (int num = 1;!list2.isEmpty();num++){
System.out.println(num+" - "+list2.peekAtNextTrack().getName()+" / "+list2.peekAtNextTrack().getArtist()+" / "+list2.peekAtNextTrack().getAlbum());
list2.getNextTrack();
}
}
}
public static void outputNext2(PlayListQueue list,Queue<PlayListTrack> track){
Queue<PlayListTrack> newTrack = new LinkedList<PlayListTrack>(track);
System.out.println();
System.out.println("Currently playing: "+list.peekAtNextTrack().getName()+" / "+list.peekAtNextTrack().getArtist());
list.getNextTrack();
System.out.println("Next track to play: "+list.peekAtNextTrack().getName()+" / "+list.peekAtNextTrack().getArtist());
System.out.println("[P]lay next track");
System.out.println("[A]dd a new track");
System.out.println("[Q]uit");
Scanner in = new Scanner (System.in);
String input = in.nextLine();
if(input.equals("p")){
outputNext2(list,track);
}
if (input.equals("a")){
outputAdd2(list,newTrack);
}
if(input.equals("q")){
outputQuit2(list,newTrack);
}
}
public static void outputAdd2(PlayListQueue list1,Queue<PlayListTrack> track1){
System.out.println("Track name: Requiem For A Dying Song");
System.out.println("Artist name: Flogging Molly");
System.out.println("Album name: Float");
System.out.println();
System.out.println("New track: Requiem For A Dying Song");
System.out.println("Artist: Flogging Molly");
System.out.println("Album: Float");
System.out.print("Are you sure you want to add this track [y/n]?");
SimpleMusicTrack track = new SimpleMusicTrack("Requiem For A Dying Song","Flogging Molly","Float");
Scanner in = new Scanner (System.in);
String choose = in.nextLine();
if (choose.equals("y")){
list1.addTrack(track);
track1.add(track);
outputCurrent2(list1,track1);
}
if (choose.equals("n")){
outputCurrent2(list1,track1);
}
}
public static void outputQuit2(PlayListQueue list2,Queue<PlayListTrack> track2){
System.out.println();
System.out.println("Tracks remaining in play list");
System.out.println("------------------------------------------------------------");
if(list2.isEmpty()){
System.out.println("No tracks remaining");
}
else{
for (int num = 1; !list2.isEmpty();num++){
System.out.println(num+" - "+list2.peekAtNextTrack().getName()+" / "+list2.peekAtNextTrack().getArtist()+" / "+list2.peekAtNextTrack().getAlbum());
list2.getNextTrack();
}
}
}
}
------------------------------------------------------------------------------------------------------
SimpleMusicTrack.java
---------------------------------------------------
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class SimpleMusicTrack implements PlayListTrack {
private String name;
private String artist;
private String album;
public SimpleMusicTrack() {
name = "";
artist = "";
album = "";
}
public SimpleMusicTrack(String name, String artist, String album) {
this.name = name;
this.artist = artist;
this.album = album;
}
@Override
public String getName() {
return this.name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getArtist() {
return this.artist;
}
@Override
public void setArtist(String artist) {
this.artist = artist;
}
@Override
public String getAlbum() {
return this.album;
}
@Override
public void setAlbum(String album) {
this.album = album;
}
@Override
public boolean getNextTrack(Scanner infile) {
boolean track = true;
try {
Scanner in = new Scanner(System.in);
System.out.print("Enter file name: ");
String fname = in.nextLine();
infile = new Scanner(new File(fname));
if (!infile.hasNext()) {
track = false;
} else {
while (infile.hasNext()) {
this.name = infile.nextLine();
if (infile.hasNext() && track) {
this.artist = infile.nextLine();
} else {
track = false;
}
if (infile.hasNext() && track) {
this.album = infile.nextLine();
} else {
track = false;
}
}
}
infile.close();
} catch (IOException e) {
System.out.println("Error in the file");
}
return track;
}
@Override
public String toString() {
return "'" + this.artist + " / " + this.album + "'";
}
@Override
public boolean equals(Object obj) {
boolean equals = true;
if (obj instanceof PlayListTrack) {
PlayListTrack track = (PlayListTrack) obj;
if (this.album.equals(track.getAlbum()) && this.name.equals(track.getName()) && this.artist.equals(track.getArtist())) {
equals = true;
} else {
equals = false;
}
}
return equals;
}
}
--------------------------------------------------------------------------------------------
simplePlayList.java
-----------------------------------------------------------
import java.util.ArrayList;
public class SimplePlayList implements PlayList {
private ArrayList<PlayListTrack> track;
public SimplePlayList(){
track = new ArrayList<PlayListTrack>();
}
public SimplePlayList (ArrayList<PlayListTrack> track1){
this.track = track1;
}
@Override
public PlayListTrack getNextTrack() {
// Removes track from PlayList and returns it to the caller
// Should return a null value if the PlayList is empty
if (track.size()==0){
return null;
}
else{
return track.remove(0);
}
}
@Override
public PlayListTrack peekAtNextTrack() {
// Returns next entry to the caller, but leaves it in the list
if (track.size()==0){
return null;
}
else{
return track.get(0);
}
}
@Override
public void addTrack(PlayListTrack track) {
// Adds this track to the playlist in the appropriate order
this.track.add(this.track.size(), track);
}
@Override
public boolean isEmpty() {
// Returns true if the playlist is empty return false;
if (track.size() == 0){
return true;
}
else{
return false;
}
}
}
------------------------------------------------------------------------------------------------
PlayListTrack.java
-----------------------------------------------------
import java.util.Scanner;
public interface PlayListTrack {
public String getName();
public void setName(String name);
public String getArtist();
public void setArtist(String artist);
public String getAlbum();
public void setAlbum(String album);
public boolean getNextTrack(Scanner infile);
}
---------------------------------------------------------------------------------------------
PlayListStack.java
---------------------------------------
import java.util.Stack;
public class PlayListStack implements PlayList {
private Stack<PlayListTrack> trackS;
public PlayListStack(){
trackS = new Stack<PlayListTrack>();
}
public PlayListStack (Stack<PlayListTrack> track1){
this.trackS = track1;
}
@Override
public PlayListTrack getNextTrack() {
// Removes track from PlayList and returns it to the caller
// Should return a null value if the PlayList is empty
if (trackS.size()==0){
return null;
}
else{
return trackS.pop();
}
}
@Override
public PlayListTrack peekAtNextTrack() {
// Returns next entry to the caller, but leaves it in the list
if (trackS.size()==0){
return null;
}
else{
return trackS.peek();
}
}
@Override
public void addTrack(PlayListTrack track) {
// Adds this track to the playlist in the appropriate order
this.trackS.push(track);
}
@Override
public boolean isEmpty() {
// Returns true if the playlist is empty return false;
if (trackS.size() == 0){
return true;
}
else{
return false;
}
}
}
----------------------------------------------------------------------------------
PlayListQueue.java
------------------------------------------
import java.util.LinkedList;
import java.util.Queue;
public class PlayListQueue implements PlayList {
private Queue<PlayListTrack> trackQ;
public PlayListQueue(){
trackQ = new LinkedList<PlayListTrack>();
}
public PlayListQueue (Queue<PlayListTrack> track1){
this.trackQ = track1;
}
@Override
public PlayListTrack getNextTrack() {
// Removes track from PlayList and returns it to the caller
// Should return a null value if the PlayList is empty
if (trackQ.size()==0){
return null;
}
else{
return trackQ.remove();
}
}
@Override
public PlayListTrack peekAtNextTrack() {
// Returns next entry to the caller, but leaves it in the list
if (trackQ.size()==0){
return null;
}
else{
return trackQ.peek();
}
}
@Override
public void addTrack(PlayListTrack track) {
// Adds this track to the playlist in the appropriate order
this.trackQ.add(track);
}
@Override
public boolean isEmpty() {
// Returns true if the playlist is empty return false;
if (trackQ.size() == 0){
return true;
}
else{
return false;
}
}
}
--------------------------------------------------------------------------------------
PlayList.java
-------------------------------------------
public interface PlayList {
public PlayListTrack getNextTrack();
// Removes track from PlayList and returns it to the caller
// Should return a null value if the PlayList is empty
public PlayListTrack peekAtNextTrack();
// Returns next entry to the caller, but leaves it in the list
public void addTrack(PlayListTrack track);
// Adds this track to the playlist in the appropriate order
public boolean isEmpty();
// Returns true if the playlist is empty
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.