added driver, added equals for objects
This commit is contained in:
parent
9828dd1b0c
commit
14a6f006d5
10
fmframework/src/sarsoo/fmframework/drive/Driver.java
Normal file
10
fmframework/src/sarsoo/fmframework/drive/Driver.java
Normal file
@ -0,0 +1,10 @@
|
||||
package sarsoo.fmframework.drive;
|
||||
|
||||
public class Driver {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println("Hello World");
|
||||
}
|
||||
|
||||
}
|
@ -12,9 +12,9 @@ public class Album extends FMObj{
|
||||
protected ArrayList<Tag> tagList;
|
||||
protected ArrayList<Track> trackList;
|
||||
|
||||
public Album(String name) {
|
||||
public Album(String name, String artist) {
|
||||
super(name, null, null, 0, 0, 0, null);
|
||||
this.name = name;
|
||||
this.artist = Artist.getArtist(artist, "sarsoo");
|
||||
}
|
||||
|
||||
public Album(String name, String url, String mbid, Artist artist, int listeners, int playCount, int userPlayCount, Wiki wiki) {
|
||||
@ -27,6 +27,10 @@ public class Album extends FMObj{
|
||||
|
||||
}
|
||||
|
||||
public Artist getArtist() {
|
||||
return artist;
|
||||
}
|
||||
|
||||
public static Album getAlbum(String name, String artist, String username) {
|
||||
String url = Network.getAlbumInfoUrl(name, artist, username);
|
||||
Document response = Network.getResponse(url);
|
||||
@ -34,4 +38,27 @@ public class Album extends FMObj{
|
||||
return album;
|
||||
}
|
||||
|
||||
public ArrayList<Track> getTrackList(){
|
||||
return trackList;
|
||||
}
|
||||
|
||||
public Track getTrack(int track) {
|
||||
return trackList.get(track);
|
||||
}
|
||||
|
||||
public ArrayList<Tag> getTags(){
|
||||
return tagList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj.getClass() != this.getClass()) return false;
|
||||
|
||||
Album album = (Album)obj;
|
||||
if(getName() == album.getName())
|
||||
if(getArtist().equals(album.getArtist()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ public class Artist extends FMObj{
|
||||
protected boolean streamable;
|
||||
protected boolean onTour;
|
||||
protected ArrayList<Album> albums;
|
||||
protected ArrayList<Track> tracks;
|
||||
protected ArrayList<Artist> similarArtists;
|
||||
protected ArrayList<Tag> tagList;
|
||||
|
||||
@ -33,4 +32,27 @@ public class Artist extends FMObj{
|
||||
Artist artist = Parser.parseArtist(response);
|
||||
return artist;
|
||||
}
|
||||
|
||||
public ArrayList<Album> getAlbum(){
|
||||
return albums;
|
||||
}
|
||||
|
||||
public ArrayList<Artist> getSimilarArtists(){
|
||||
return similarArtists;
|
||||
}
|
||||
|
||||
public ArrayList<Tag> getTags(){
|
||||
return tagList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj.getClass() != this.getClass()) return false;
|
||||
|
||||
Artist artist = (Artist)obj;
|
||||
if(getName() == artist.getName())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -31,4 +31,24 @@ public class Track extends FMObj{
|
||||
Track track = Parser.parseTrack(response);
|
||||
return track;
|
||||
}
|
||||
|
||||
public Artist getArtist() {
|
||||
return artist;
|
||||
}
|
||||
|
||||
public ArrayList<Tag> getTags(){
|
||||
return tagList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj.getClass() != this.getClass()) return false;
|
||||
|
||||
Track track = (Track)obj;
|
||||
if(getName() == track.getName())
|
||||
if(getArtist().equals(track.getArtist()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class Parser {
|
||||
// System.out.println(summary);
|
||||
// System.out.println(content);
|
||||
|
||||
Artist artistObj = new Artist(artist);
|
||||
Artist artistObj = Artist.getArtist(artist, "Sarsoo");
|
||||
Wiki wiki = new Wiki();
|
||||
|
||||
Album album = new Album(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
|
||||
@ -83,7 +83,7 @@ public class Parser {
|
||||
int playCount = Integer.parseInt(doc.getElementsByTagName("playcount").item(0).getTextContent());
|
||||
int userPlayCount = Integer.parseInt(doc.getElementsByTagName("userplaycount").item(0).getTextContent());
|
||||
|
||||
Artist artistObj = new Artist(artistName);
|
||||
Artist artistObj = Artist.getArtist(artistName, "sarsoo");
|
||||
|
||||
// System.out.println(userPlayCount);
|
||||
|
||||
|
17
fmframework/src/sarsoo/fmframework/test/AlbumTest.java
Normal file
17
fmframework/src/sarsoo/fmframework/test/AlbumTest.java
Normal file
@ -0,0 +1,17 @@
|
||||
package sarsoo.fmframework.test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import sarsoo.fmframework.music.Album;
|
||||
|
||||
class AlbumTest {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
Album album = Album.getAlbum("Recovery", "Eminem", "sarsoo");
|
||||
System.out.println(album.getArtist());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user