package agenda; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * Created by gjoosen on 06/02/15. */ public class Agenda implements Serializable { private List stages; private List artists; private List acts; public Agenda() { this.stages = new ArrayList(); this.artists = new ArrayList(); this.acts = new ArrayList(); this.testAgenda(); System.out.println("first acttime: " + this.firstActTime()); } private void testAgenda(){ //stages this.stages.add(new Stage("Main stage")); this.stages.add(new Stage("Tent stage")); //artiesten this.artists.add(new Artist("Iron Maiden", "Heavy metal")); this.artists.add(new Artist("Slayer", "Tresh metal")); this.artists.add(new Artist("Sabaton", "Power metal")); //acts this.acts.add(new Act(this.artists.get(0).getName(), this.stages.get(0), "Heavy metal", new ActTime(2015,02,11,21,00 ,2015,02,11,23,00), 5, this.artists.get(0))); this.acts.add(new Act(this.artists.get(1).getName(), this.stages.get(1), "Test metal" , new ActTime(2015,02,10,23,00 ,2015,02,12,04,30), 5, this.artists.get(1))); this.acts.add(new Act(this.artists.get(2).getName(), this.stages.get(0), "Power metal" ,new ActTime(2015,02,11,20,00 ,2015,02,11,23,00), 4, this.artists.get(2))); //System.out.println(this); } public List getStages() { return stages; } public void addStage(Stage stage){ this.stages.add(stage); } public void addArtist(Artist artist){ this.artists.add(artist); } /** * returns the first ActTime of all the acts. * @return first ActTime of all acts */ public ActTime firstActTime(){ List acts = this.getActs(); List actTimes = new ArrayList(); for(Act act: acts){ actTimes.add(act.getActTime()); } Collections.sort(actTimes); return actTimes.get(0); } public void addAct(Act act){ this.acts.add(act); System.err.println(this.acts); } public List getArtists() { return artists; } public List getActs() { return acts; } public void removeStage(Object obj){ this.stages.remove(obj); } public void removeArtist(Artist artist){ this.artists.remove(artist); } public void removeAct(Act act){ this.acts.remove(act); } @Override public String toString(){ String string = ""; for(Act act: this.acts){ string += act + "\n\n"; } return string; } }