Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sp2fy;
- import java.util.ArrayList;
- public class Playlist {
- //atributos
- private String nomePlaylist;
- private ArrayList<Musica> playlist;
- //construtor
- public Playlist(String nomePlaylist){
- this.nomePlaylist = nomePlaylist;
- playlist = new ArrayList<Musica>();
- }
- public String getNomePlaylist() {
- return this.nomePlaylist;
- }
- public void setNomePlaylist(String nomePlaylist) {
- this.nomePlaylist = nomePlaylist;
- }
- public boolean removeMusicaDaPlaylist(String nomeMusica) {
- return this.playlist.remove(nomeMusica);
- }
- public Object getMusicaDaPlaylist(String musica) throws Exception {
- for (int i = 0; i < this.playlist.size(); i += 1) {
- if (musica.equals(this.playlist.get(i))) {
- return this.playlist.get(i);
- }
- }
- return false;
- }
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((this.nomePlaylist == null) ? 0 : this.nomePlaylist.hashCode());
- return result;
- }
- public boolean equals(Object obj) {
- if (obj instanceof Playlist) {
- Playlist outraPlaylist = (Playlist) obj;
- if (this.getNomePlaylist().equals(outraPlaylist.getNomePlaylist())) {
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement