Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public class Song {
  2. private String title;
  3. private String album;
  4. private String artist;
  5. private int songLength;
  6.  
  7. public Song() {
  8. title = "";
  9. album = "";
  10. artist = "";
  11. songLength = 0;
  12. }
  13.  
  14. public Song(String t, String al, String ar, int length) {
  15. title = t;
  16. album = al;
  17. artist = ar;
  18. songLength = length;
  19. }
  20.  
  21. public void setTitle(String t) { title = t; }
  22.  
  23. public void setAlbum(String al) { album = al; }
  24.  
  25. public void setArtist(String ar) { artist = ar; }
  26.  
  27. public void setLength(int length) { songLength = length; }
  28.  
  29. public String getTitle() { return title; }
  30.  
  31. public String getAlbum() { return album; }
  32.  
  33. public String getArtist() { return artist; }
  34.  
  35. public int getLength() { return songLength; }
  36.  
  37. public boolean equals(Object obj) {
  38. Song s = (Song) obj;
  39. if (s != null) {
  40. return this.getTitle().equals(s.getTitle()) &&
  41. this.getAlbum().equals(s.getAlbum()) &&
  42. this.getArtist().equals(s.getArtist()) &&
  43. this.getLength() == s.getLength();
  44. }
  45. return false;
  46. }
  47.  
  48. public String toString() {
  49. return "title: " + title + ", album: " + album + ", artist: " + artist + ", length: " + songLength;
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement