diff --git a/fmframework/src/sarsoo/fmframework/drive/Driver.java b/fmframework/src/sarsoo/fmframework/drive/Driver.java new file mode 100644 index 0000000..5209141 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/drive/Driver.java @@ -0,0 +1,10 @@ +package sarsoo.fmframework.drive; + +public class Driver { + + public static void main(String[] args) { + + System.out.println("Hello World"); + } + +} diff --git a/fmframework/src/sarsoo/fmframework/music/Album.java b/fmframework/src/sarsoo/fmframework/music/Album.java index 85089b2..bc7c2fa 100644 --- a/fmframework/src/sarsoo/fmframework/music/Album.java +++ b/fmframework/src/sarsoo/fmframework/music/Album.java @@ -12,9 +12,9 @@ public class Album extends FMObj{ protected ArrayList tagList; protected ArrayList 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 getTrackList(){ + return trackList; + } + + public Track getTrack(int track) { + return trackList.get(track); + } + + public ArrayList 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; + } } diff --git a/fmframework/src/sarsoo/fmframework/music/Artist.java b/fmframework/src/sarsoo/fmframework/music/Artist.java index 6b1b38b..a0fa144 100644 --- a/fmframework/src/sarsoo/fmframework/music/Artist.java +++ b/fmframework/src/sarsoo/fmframework/music/Artist.java @@ -11,7 +11,6 @@ public class Artist extends FMObj{ protected boolean streamable; protected boolean onTour; protected ArrayList albums; - protected ArrayList tracks; protected ArrayList similarArtists; protected ArrayList tagList; @@ -33,4 +32,27 @@ public class Artist extends FMObj{ Artist artist = Parser.parseArtist(response); return artist; } + + public ArrayList getAlbum(){ + return albums; + } + + public ArrayList getSimilarArtists(){ + return similarArtists; + } + + public ArrayList 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; + } } diff --git a/fmframework/src/sarsoo/fmframework/music/Track.java b/fmframework/src/sarsoo/fmframework/music/Track.java index 12efc13..a72bfcb 100644 --- a/fmframework/src/sarsoo/fmframework/music/Track.java +++ b/fmframework/src/sarsoo/fmframework/music/Track.java @@ -31,4 +31,24 @@ public class Track extends FMObj{ Track track = Parser.parseTrack(response); return track; } + + public Artist getArtist() { + return artist; + } + + public ArrayList 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; + } } diff --git a/fmframework/src/sarsoo/fmframework/parser/Parser.java b/fmframework/src/sarsoo/fmframework/parser/Parser.java index 33b30b7..f29eae2 100644 --- a/fmframework/src/sarsoo/fmframework/parser/Parser.java +++ b/fmframework/src/sarsoo/fmframework/parser/Parser.java @@ -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); diff --git a/fmframework/src/sarsoo/fmframework/test/AlbumTest.java b/fmframework/src/sarsoo/fmframework/test/AlbumTest.java new file mode 100644 index 0000000..e6d4932 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/test/AlbumTest.java @@ -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()); + } + +}