Question: Java Eclipse Objective: Write a program where a user can enter a number of songs into a playlist and then simulates the playlist being played.

Java Eclipse

Objective:

Write a program where a user can enter a number of songs into a playlist and then simulates the playlist being played. This solution requires the following:

A class Song

  • Attributes:
    • Name: the name of the song
    • Artist: the name of the artist of the song
    • Total Length: the length of the song given in seconds. This is assumed to be positive and includes 0.
    • Current Time: the current second the song is on
  • Accessors and Mutators for all Attributes
    • Mutators MUST check for valid values
  • Other Methods
    • toString: has no parameters and returns a string with the name, artist, and total length
    • getTimeRemaining: This method returns (the total length current time).

A generic Queue of your own creation

  • You may implement this as either an array or a linked list
  • Must have the methods
    • Enqueue
    • Dequeue
    • Peek
    • Print

A class SongPlaylist

  • Attributes:
    • Queue of Songs
  • Other Methods:
    • addSong: This method takes in an instance of a song and then adds it to the queue of songs. It returns nothing.
    • getCurrentSong: returns but does not remove the song that is at the beginning of the queue
    • advanceOneSecond: This advances the current song by one second. If the songs remaining time is less than 0, then it must remove the current song and start the next song when this method is called next.

A class SongPlaylistFrontEnd

  • A simple, front end where the user can add songs, play the playlist, or quit via the console.
  • When playing the playlist it should print out information about the song every simulated second. You may use a loop with a counter to simulate time passing.

Example Dialog:

Welcome to the Song Playlist!

Enter 1: to Add a Song

Enter 2: to Start the Playlist

Enter 9: to Quit

1

Enter the name, the artist, and the total time (seconds)

Test Song 1

Test Artist 1

60

Enter 1: to Add a Song

Enter 2: to Start the Playlist

Enter 9: to Quit

1

Enter the name, the artist, and the total time (seconds)

Test Song 2

Test Artist 2

30

Enter 1: to Add a Song

Enter 2: to Start the Playlist

Enter 9: to Quit

1

Enter the name, the artist, and the total time (seconds)

Test Song 3

Test Artist 3

90

Enter 1: to Add a Song

Enter 2: to Start the Playlist

Enter 9: to Quit

1

Enter the name, the artist, and the total time (seconds)

Test Song 4

Test Artist 4

120

Enter 1: to Add a Song

Enter 2: to Start the Playlist

Enter 9: to Quit

2

Starting the Playlist

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 0

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 1

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 2

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 3

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 4

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 5

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 6

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 7

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 8

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 9

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 10

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 11

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 12

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 13

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 14

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 15

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 16

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 17

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 18

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 19

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 20

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 21

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 22

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 23

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 24

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 25

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 26

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 27

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 28

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 29

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 30

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 31

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 32

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 33

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 34

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 35

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 36

Name: Test Song 1 Artist: Test Artist 1 Length: 60 Elapsed Time: 37

and so on...

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!