Agenda.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package agenda;
  2. import java.io.Serializable;
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5. import java.util.List;
  6. /**
  7. * Created by gjoosen on 06/02/15.
  8. */
  9. public class Agenda implements Serializable {
  10. private List<Stage> stages;
  11. private List<Artist> artists;
  12. private List<Act> acts;
  13. public Agenda() {
  14. this.stages = new ArrayList<Stage>();
  15. this.artists = new ArrayList<Artist>();
  16. this.acts = new ArrayList<Act>();
  17. this.testAgenda();
  18. System.out.println("first acttime: " + this.firstActTime());
  19. }
  20. private void testAgenda(){
  21. //stages
  22. this.stages.add(new Stage("Main stage"));
  23. this.stages.add(new Stage("Tent stage"));
  24. //artiesten
  25. this.artists.add(new Artist("Iron Maiden", "Heavy metal"));
  26. this.artists.add(new Artist("Slayer", "Tresh metal"));
  27. this.artists.add(new Artist("Sabaton", "Power metal"));
  28. //acts
  29. 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)));
  30. 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)));
  31. 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)));
  32. //System.out.println(this);
  33. }
  34. public List<Stage> getStages() {
  35. return stages;
  36. }
  37. public void addStage(Stage stage){
  38. this.stages.add(stage);
  39. }
  40. public void addArtist(Artist artist){
  41. this.artists.add(artist);
  42. }
  43. /**
  44. * returns the first ActTime of all the acts.
  45. * @return first ActTime of all acts
  46. */
  47. public ActTime firstActTime(){
  48. List<Act> acts = this.getActs();
  49. List<ActTime> actTimes = new ArrayList<ActTime>();
  50. for(Act act: acts){
  51. actTimes.add(act.getActTime());
  52. }
  53. Collections.sort(actTimes);
  54. return actTimes.get(0);
  55. }
  56. public void addAct(Act act){
  57. this.acts.add(act);
  58. System.err.println(this.acts);
  59. }
  60. public List<Artist> getArtists() {
  61. return artists;
  62. }
  63. public List<Act> getActs() {
  64. return acts;
  65. }
  66. public void removeStage(Object obj){
  67. this.stages.remove(obj);
  68. }
  69. public void removeArtist(Artist artist){
  70. this.artists.remove(artist);
  71. }
  72. public void removeAct(Act act){
  73. this.acts.remove(act);
  74. }
  75. @Override
  76. public String toString(){
  77. String string = "";
  78. for(Act act: this.acts){
  79. string += act + "\n\n";
  80. }
  81. return string;
  82. }
  83. }