/* * ListeningHistory - Represents the listening history of a user. Contains weeks which reference artists. */ class ListeningHistory{ int totalPlays; // total plays within this history String username; // the Last.FM username Artists artists; // reference to the list of artists Weeks weeks; // reference to the list of weeks ListeningHistory(String username){ this.username = username; totalPlays = 0; artists = new Artists(this); weeks = new Weeks(this); } int getTotalPlays(){ return totalPlays; } Artists getArtists(){ return artists; } Weeks getWeeks(){ return weeks; } ListeningHistory filterByPopularity(float popularity){ return filterByPopularity(1, popularity); } ListeningHistory filterByPopularity(float max, float min){ // create a new history file ListeningHistory filteredHistory = new ListeningHistory(this.username); // loop through the weeks for(int w=0; w= min){ // create a new artist Artist newArtist = filteredHistory.artists.addArtist(artist.getName()); // add the artist to the week lineup filteredWeek.addArtist(newArtist); // add the plays to the artist for this particular week newArtist.addPlays(filteredWeek, artist.getPlays(week)); } } } // return the new history data return filteredHistory; } void loadData(){ // get the data file BufferedReader data = createReader("data/histories/"+username+".dat"); try{ // first line: load in how many weeks there are String[] header = split(data.readLine(),","); int weekCount = int(header[1]); // skip a line data.readLine(); // read in the weeks for(int w=0; w