Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you only need to write playlist and UserCollection classes. before diving deep into each class, write stubs for each class so that your code compiles.

you only need to write playlist and UserCollection classes.

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribed

before diving deep into each class, write stubs for each class so that your code compiles.

Java code for please help

L PL Playlist.java This class will keep track of a playlist. public Playlist(String name) - constructs a new instance of the Playlist class with the specified name. 2 public Playlist(String name, List contents) - constructs a new instance of the Playlist class with the specified name and songs. public String getName() - returns the name of the playlist. public void addSong(Song song) - adds the specified song to the playlist. public void play() - plays the playlist. In order to "play" a song, you just need to print each song out. Remember that a song already knows how to describe itself with its toString() method. public void shuffle() - shuffle the songs in the playlist so they play in a different random order next time. public void removeSong(Song song) - remove the passed in song from the playlist if it exists in the playlist. UserCollection.java This class tracks all of the users in Spotify. public UserCollection() - constructs a new instance of the UserCollection class. public boolean userExists(String username) - returns true if a user with the specified username exists. 3 public User login(String username, String password) - returns the User associated with the login credentials if it was a valid login or returns null if the login was invalid. public void addUser(User add) - adds this user to the collection of all users. public String toString() - returns a string description of all the users. For example if there were two users (tconklin, cjenkins) both with 0 playlists, toString() should return "{ cjenkins: cjenkins, 0 playlists, toonklin: tconklin, 0 playlists, }. Song.java This class collects methods/data for a song. public Song(String title, String artist) - construct a new instance of the Song class with the specified song title and artist. public String getTitle() - return the title of the song. public String getArtist() - return the artist of the song. public int getTimesPlayed() - return the number of times this song has been played. public void play() - "play" this song. To play a song you just print out a description of the song. public String toString() - return a string description of this song. It should be of the format: title by artist, timesPlayed play(s). So if you have the song God's Plan by Drake and it has been played 27 times, it should return "God's Plan by Drake, 27 play(s)" Library.java This class must keep track of the library of songs in your Spotify program. This comes from the file in songFiles. That filename is passed in as a command-line argument. public Library() - constructs a new instance of this class. public Song getSong(String title) - returns the Song associated with the String title passed in if it exists in the library, or null if the song does not exist in the library. public ListgetAllSongs() - returns a list of all the songs in the library. public void addSong(Song song) - adds the passed in song to the library. public void remove Song(Song song) - removes the passed in song from the library if it exists in the library. public String toString() - returns a string representation of this library. The format is to have the string representation of each song on its own line. So you want to add the string representation of a song, then a newline for each song. User.java This class bundles methods/data for a User object. public User(String name, String password) - constructs a new instance of the User class with the specified name and password. public String getName() - returns the name of the user. public boolean attempt Login(String password) - returns true if the password is valid for this user. False otherwise. public void addPlaylist(Playlist newPlaylist) - adds the specified playlist to the user's playlists. public List getPlaylists() - returns a list of the playlists for this user. public void selectPlaylist(String name) - selects the playlist with the specified name if the user has a playlist by that name and plays the newly selected playlist. public String toString() - returns a string description of the user. The format is name, numPlaylists playlists. So if I had a user cjenkins who had 12 playlists this method would return "cjenkins, 12 playlists

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions