Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. Set<Song> findSongsBySinger(Singer singer) {
  2. Set<Song> set = new HashSet<>();
  3. for (Song song : catalog.getSongs()) {
  4. if (song.getSinger().equals(singer)) {
  5. set.add(song);
  6. }
  7. }
  8. return set;
  9. }
  10.  
  11. Set<Song> findSongsByAlbum(Album album) {
  12. Set<Song> set = new HashSet<>();
  13. for (Song song : catalog.getSongs()) {
  14. if (song.getAlbum().equals(album)) {
  15. set.add(song);
  16. }
  17. }
  18. return set;
  19. }
  20.  
  21. Set<Song> findSongsByCollection(SongsCollection collection) {
  22. return collection.getSongs();
  23. }
  24.  
  25. Set<Song> findSongsByGenre(Genre genre) {
  26. Set<Song> set= new HashSet<>();
  27. for (Song song : catalog.getSongs()) {
  28. if (song.getGenre().equals(genre) || song.getGenre().getParent() != null && song.getGenre().getParent().equals(genre)) {
  29. set.add(song);
  30. }
  31. }
  32. return set;
  33. }
  34.  
  35. Set<Song> findSongsEqualsYear(int year) {
  36. Set<Song> set = new HashSet<>();
  37. for (Song song : catalog.getSongs()) {
  38. if (song.getYear() == year) {
  39. set.add(song);
  40. }
  41. }
  42. return set;
  43. }
  44.  
  45. Set<Singer> findSingersBySongCollection(SongsCollection collection) {
  46. Set<Singer> set = new HashSet<>();
  47. for (Song song : collection.getSongs()) {
  48. set.add(song.getSinger());
  49. }
  50. return set;
  51. }
  52.  
  53.  
  54. Set<Album> findAlbumsByGenre(Genre genre) {
  55. Set<Album> set = new HashSet<>();
  56. for (Song song : catalog.getSongs()) {
  57. if (song.getGenre().equals(genre) || song.getGenre().getParent() != null && song.getGenre().getParent().equals(genre)) {
  58. set.add(song.getAlbum());
  59. }
  60. }
  61. return set;
  62. }
  63.  
  64. Set<SongsCollection> findSongsCollectionBySongs(Set<Song> songsSet) {
  65. Set<SongsCollection> songsCollectionsSet = new HashSet<>();
  66. for (SongsCollection songsCollection : catalog.getSongsCollections()) {
  67. for (Song song : songsCollection.getSongs()) {
  68. if (songsSet.contains(song)) {
  69. songsCollectionsSet.add(songsCollection);
  70. }
  71. }
  72. }
  73. return songsCollectionsSet;
  74. }
  75.  
  76. Set<Genre> findGenresBySongsCollection(SongsCollection collection) {
  77. Set<Genre> set = new HashSet<>();
  78. for (Song song : collection.getSongs()) {
  79. set.add(song.getGenre());
  80. }
  81. return set;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement