소스 검색

Expanded the agenda, added a hard coded test situation for the agenda (text based).

Gilian Joosen 11 년 전
부모
커밋
e0d86b71fb
6개의 변경된 파일87개의 추가작업 그리고 16개의 파일을 삭제
  1. 8 7
      src/GUI/GUI.java
  2. 23 6
      src/agenda/Act.java
  3. 18 1
      src/agenda/ActTime.java
  4. 22 2
      src/agenda/Agenda.java
  5. 15 0
      src/agenda/Time.java
  6. 1 0
      test/src/agenda/ActTimeTest.java

+ 8 - 7
src/GUI/GUI.java

@@ -43,14 +43,15 @@ public class GUI {
         
         //test agenda.
         Agenda agenda = new Agenda();
-        agenda.addArtist(new Artist("Iron Maiden", "Heavy metal"));
-        agenda.addStage(new Stage("Mainstage"));
-        agenda.addAct(new Act(agenda.getStages().get(0), "Heavy metal", agenda.getArtists().get(0)));
         
-        System.out.println(agenda);
-        
-        //test time
-        System.out.println(new ActTime(new Time(10, 30), new Time(11, 20)).getLength());
+//        agenda.addArtist(new Artist("Iron Maiden", "Heavy metal"));
+//        agenda.addStage(new Stage("Mainstage"));
+//        agenda.addAct(new Act(agenda.getStages().get(0), "Heavy metal", agenda.getArtists().get(0)));
+//
+//        System.out.println(agenda);
+//
+//        //test time
+//        System.out.println(new ActTime(new Time(10, 30), new Time(11, 20)).getLength());
 	}
 
 	/**

+ 23 - 6
src/agenda/Act.java

@@ -13,30 +13,47 @@ public class Act {
     private String genre;
     private ActTime actTime;
 
-    public Act(Stage stage, String genre, Artist... artists){
+    public Act(Stage stage, String genre, Time startTime, Time endTime, Artist... artists){
         this.stage = stage; 
         this.genre = genre;
-        
+        this.actTime = new ActTime(startTime, endTime);
+
         this.artists = new ArrayList<Artist>();
         for(Artist artist: artists) {
             this.artists.add(artist);
         }
     }
 
+    /**
+     * * returns a list with all the artists that are in the act.
+     * @return all artists.
+     */
     public List<Artist> getArtists() {
         return artists;
     }
 
+    /**
+     * * returns the stage the act plays on.
+     * @return stage
+     */
     public Stage getStage() {
         return stage;
     }
 
+    /**
+     * * returns the genre of the act.
+     * @return the genre of the act.
+     */
     public String getGenre() {
         return genre;
     }
 
-    public ActTime getActTime() {
-        return actTime;
+    /**
+     * * return the act time.
+     * @return the act time in minutes
+     */
+    public int getActTime() {
+        return this.actTime.getLength();
     }
     
     @Override
@@ -46,9 +63,9 @@ public class Act {
         for(Artist artist: this.artists){
             string += artist.getName() + "\n";
         }
-    
         string+= "genre: " + this.genre + "\n";
-        string+= "stage: " + this.stage.getName();
+        string+= "stage: " + this.stage.getName() + "\n";
+        string+= this.actTime;
         return string;
     }
 }

+ 18 - 1
src/agenda/ActTime.java

@@ -11,10 +11,27 @@ public class ActTime {
         this.beginTime = beginTime;
         this.endTime = endTime;
     }
-    
+
+    /**
+     * *
+     * @return the length of the act in minutes.
+     */
     public int getLength(){
         int difHours = this.endTime.getHours() - this.beginTime.getHours();
         int difMinutes = this.endTime.getMinutes() - this.beginTime.getMinutes();
         return difHours  * 60 + difMinutes;
     }
+
+    public Time getBeginTime() {
+        return beginTime;
+    }
+
+    public Time getEndTime() {
+        return endTime;
+    }
+    
+    @Override
+    public String toString(){
+        return "start time: " + this.beginTime + "\nend time: " + this.endTime;
+    }
 }

+ 22 - 2
src/agenda/Agenda.java

@@ -16,8 +16,28 @@ public class Agenda {
         this.stages = new ArrayList<Stage>();
         this.artists = new ArrayList<Artist>();
         this.acts = new ArrayList<Act>();
+        
+        this.testAgenda();
     }
 
+    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.stages.get(0), "Heavy metal", new Time(21, 00), new Time(23, 00), this.artists.get(0)));
+        this.acts.add(new Act(this.stages.get(1), "Test metal" ,new Time(10, 10), new Time(10, 50), this.artists.get(1)));
+        this.acts.add(new Act(this.stages.get(0), "Power metal" ,new Time(10, 10), new Time(10, 50), this.artists.get(2)));
+        
+        System.out.println(this);
+    }
+    
     public List<Stage> getStages() {
         return stages;
     }
@@ -46,8 +66,8 @@ public class Agenda {
     public String toString(){
         String string = "";
         for(Act act: this.acts){
-            string += act + "\n";
+            string += act + "\n\n";
         }
-        return string;        
+        return string;
     }
 }

+ 15 - 0
src/agenda/Time.java

@@ -19,4 +19,19 @@ public class Time {
     public int getMinutes() {
         return minutes;
     }
+    
+    @Override
+    public String toString(){
+        return this.numberToTimeDigits(this.hours) + ":" + this.numberToTimeDigits(this.minutes);
+    }
+    
+    private String numberToTimeDigits(int h){
+        String hours;
+        if(h == 0 || h == 1 || h == 2 || h == 3 || h == 4 || h == 5 || h == 6 || h == 7 || h == 8 || h == 9){
+            hours = "0" + h;
+        }else {
+            hours = String.valueOf(h);
+        }
+        return hours;
+    }
 }

+ 1 - 0
test/src/agenda/ActTimeTest.java

@@ -6,6 +6,7 @@ public class ActTimeTest extends TestCase{
 
     @org.junit.Before
     public void setUp() throws Exception {
+        
     }
 
     @org.junit.Test