Artist Class
package com.spconger; public class Artist { private String artistName; private String artistURL; private String artistInfo; public String getArtistName() { return artistName; } public void setArtistName(String artistName) { this.artistName = artistName; } public String getArtistURL() { return artistURL; } public void setArtistURL(String artistURL) { this.artistURL = artistURL; } public String getArtistInfo() { return artistInfo; } public void setArtistInfo(String artistInfo) { this.artistInfo = artistInfo; } }
Here is the fan Class
package com.spconger; import java.util.ArrayList; public class Fan { private String Name; private String Email; private ArrayList<Artist>followArtists; private ArrayList<String> genres; private ArrayList<String> alerts; public Fan() { followArtists = new ArrayList<Artist>(); } public String getName() { return Name; } public void setName(String name) { Name = name; } public String getEmail() { return Email; } public void setEmail(String email) { Email = email; } public ArrayList<Artist> getFollowArtists() { return followArtists; } public void AddArtist(Artist a){ followArtists.add(a); } public void RemoveArtist(Artist a){ followArtists.remove(a); } }
Here is the Program class where I call the classes and methods
package com.spconger; import java.util.ArrayList; public class Program { public static void main(String[] args) { Fan f = new Fan(); f.setName("Joe Demaggio"); f.setEmail("JD@gmail.com"); Artist a1 = new Artist(); a1.setArtistName("ACDC"); f.AddArtist(a1); Artist a2 = new Artist(); a2.setArtistName("Bob Dylan"); f.AddArtist(a2); Artist a3 = new Artist(); a3.setArtistName("Ozzy Osborne"); f.AddArtist(a3); ArrayList<Artist>artists = f.getFollowArtists(); for(Artist a : artists){ System.out.println(a.getArtistName()); } System.out.println(); f.RemoveArtist(a1); ArrayList<Artist>artists1 = f.getFollowArtists(); for(Artist a : artists1){ System.out.println(a.getArtistName()); } } }
No comments:
Post a Comment