peshopbs2

Untitled

Dec 5th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. package program;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public class Playlist {
  7. private List<Song> songs = new ArrayList<Song>();
  8. private String playlistName;
  9. public List<Song> getSongs() {
  10. return songs;
  11. }
  12. public void setSongs(List<Song> songs) {
  13. this.songs = songs;
  14. }
  15. public String getPlaylistName() {
  16. return playlistName;
  17. }
  18. public void setPlaylistName(String playlistName) {
  19. this.playlistName = playlistName;
  20. }
  21. @Override
  22. public String toString() {
  23. return "Playlist [songs=" + songs + ", playlistName=" + playlistName + "]";
  24. }
  25. public Playlist(List<Song> songs, String playlistName) {
  26. super();
  27. this.songs = songs;
  28. this.playlistName = playlistName;
  29. }
  30.  
  31. public void add(Song song) {
  32. this.songs.add(song);
  33. }
  34.  
  35. public Song get(int index) {
  36. return this.songs.get(index);
  37. }
  38.  
  39. public Song remove(int index) {
  40. return this.songs.remove(index);
  41. }
  42.  
  43. public void printPlaylist() {
  44. for (Song song : songs) {
  45. System.out.println(song);
  46. }
  47. System.out.println("------------------------------------");
  48. }
  49. }
Add Comment
Please, Sign In to add comment