diff --git a/Agenda b/Agenda new file mode 100644 index 0000000..07ce3bd --- /dev/null +++ b/Agenda @@ -0,0 +1,188 @@ +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.ArrayList; + +public class Agenda implements Serializable { + + private static final long serialVersionUID = 1; + + private ArrayList stages; + private ArrayList events; + private ArrayList artists; + + public Agenda() { + stages = new ArrayList(); + events = new ArrayList(); + artists = new ArrayList(); + } + + public void addStage(Stage stage) { + stages.add(stage); + } + + public void addEvent(Event event) { + events.add(event); + } + + public void addArtist(Artist artist) { + artists.add(artist); + } + + public void fillArtists() { + FileInputStream fis = null; + ObjectInputStream ois = null; + + try { + fis = new FileInputStream("artists.dat"); + ois = new ObjectInputStream(fis); + + Object object; + object = ois.readObject(); + try { + while (object != null) { + artists.add((Artist) object); + object = ois.readObject(); + } + } catch (EOFException e) { + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void fillEvents() { + FileInputStream fis = null; + ObjectInputStream ois = null; + + try { + fis = new FileInputStream("events.dat"); + ois = new ObjectInputStream(fis); + + Object object; + object = ois.readObject(); + try { + while (object != null) { + events.add((Event) object); + object = ois.readObject(); + } + } catch (EOFException e) { + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + + public void fillStages() { + FileInputStream fis = null; + ObjectInputStream ois = null; + + try { + fis = new FileInputStream("stages.dat"); + ois = new ObjectInputStream(fis); + + Object object; + object = ois.readObject(); + try { + while (object != null) { + stages.add((Stage) object); + object = ois.readObject(); + } + } catch (EOFException e) { + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void saveStages() { + + try { + File file = new File("stages.dat"); + if (!file.exists()){ + file.createNewFile(); + } + FileOutputStream fos = new FileOutputStream(file); + ObjectOutputStream oos = new ObjectOutputStream(fos); + for (Stage stage : stages) { + oos.writeObject(stage); + } + oos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void saveEvents() { + + try { + File file = new File("events.dat"); + if (!file.exists()){ + file.createNewFile(); + } + FileOutputStream fos = new FileOutputStream(file); + ObjectOutputStream oos = new ObjectOutputStream(fos); + for (Event event : events) { + oos.writeObject(event); + } + oos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void saveArtists() { + + try { + File file = new File("artists.dat"); + if (!file.exists()){ + file.createNewFile(); + } + FileOutputStream fos = new FileOutputStream(file); + ObjectOutputStream oos = new ObjectOutputStream(fos); + for (Artist artist : artists) { + oos.writeObject(artist); + } + oos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void addEvents() + { + int ID = 0; + for (Stage stage : stages) + { + ID = stage.getID(); + for (Event event : events) + { + if ( ID == event.getID()) + { + stage.addEvent(event); + } + } + } + } + + public void saveAll() + { + saveArtists(); + saveEvents(); + saveStages(); + } + + public void fillAll() + { + fillArtists(); + fillEvents(); + fillStages(); + addEvents(); + } +} diff --git a/Artist b/Artist new file mode 100644 index 0000000..960fd40 --- /dev/null +++ b/Artist @@ -0,0 +1,72 @@ +import java.io.Serializable; + +import javax.swing.ImageIcon; + + +public class Artist implements Serializable{ + + private static final long serialVersionUID = 1; + + private String name; + private String genre; + private ImageIcon image; + private String description; + + public Artist(String name, String genre, String image, String description) + { + this.name = name; + this.genre = genre; + this.description = description; + + if ( !image.equals("null")) { + this.image = new ImageIcon(image); + } else { + this.image = null; + } + } + + public String getName() + { + return this.name; + } + + public String getGenre() + { + return this.genre; + } + + public ImageIcon getImage() + { + return this.image; + } + + public String getDescription() + { + return this.description; + } + + public void setName(String name) + { + this.name = name; + } + + public void setGenre(String genre) + { + this.genre = genre; + } + + public void setImageIconString(String image) + { + this.image = new ImageIcon(image); + } + + public void setImageIcon(ImageIcon image) + { + this.image = image; + } + + public void setDescription(String description) + { + this.description = description; + } +} diff --git a/Artist.java b/Artist.java deleted file mode 100644 index 911b7fa..0000000 --- a/Artist.java +++ /dev/null @@ -1,18 +0,0 @@ -import javax.swing.ImageIcon; - - -public class Artist -{ - private String genre; - private String name; - private String description; - private ImageIcon image; - private int id; - - public Artist() - { - - } - - -} diff --git a/Data.java b/Data.java deleted file mode 100644 index 148c48c..0000000 --- a/Data.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.ArrayList; - - -public class Data -{ - private ArrayList stages; - private ArrayList events; - private ArrayList artists; - - public Data() - { - // TODO Auto-generated constructor stub - } - -} diff --git a/Event b/Event new file mode 100644 index 0000000..a34ecd2 --- /dev/null +++ b/Event @@ -0,0 +1,93 @@ +import java.io.Serializable; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.GregorianCalendar; + +public class Event implements Serializable { + + private static final long serialVersionUID = 1; + + private GregorianCalendar startDate; + private GregorianCalendar endDate; + private Artist artist; + private String description; + private int expectedPopularity; + private int ID; + + public Event(int startYear, int startMonth, int startDay, int startHour, + int startMinute, int endYear, int endMonth, int endDay, + int endHour, int endMinute, Artist artist, String description, + int expectedPopularity, int ID) { + startDate = new GregorianCalendar(startYear, startMonth - 1, startDay, + startHour, startMinute); + endDate = new GregorianCalendar(endYear, endMonth - 1, endDay, endHour, + endMinute); + this.artist = artist; + this.description = description; + this.expectedPopularity = expectedPopularity; + this.ID = ID; + } + + public GregorianCalendar getStartDate() { + return this.startDate; + } + + public GregorianCalendar getEndDate() { + return this.endDate; + } + + public Artist getArtist() { + return this.artist; + } + + public String getDescription() { + return this.description; + } + + public int getID() { + return this.ID; + } + + public int getExpectedPopularity() { + return this.expectedPopularity; + } + + public void setStartDate(int startYear, int startMonth, int startDay, + int startHour, int startMinute) { + startDate.set(startYear, startMonth - 1, startDay, startHour, + startMinute); + } + + public void setEndDate(int endYear, int endMonth, int endDay, int endHour, + int endMinute) { + endDate.set(endYear, endMonth - 1, endDay, endHour, endMinute); + } + + public void setArtist(Artist artist) { + this.artist.setName(artist.getName()); + this.artist.setGenre(artist.getGenre()); + this.artist.setImageIcon(artist.getImage()); + this.artist.setDescription(artist.getDescription()); + } + + public void setDescription(String description) { + this.description = description; + } + + public void setExpectedPopularity(int popularity) { + this.expectedPopularity = popularity; + } + + public void setID(int ID) { + this.ID = ID; + } + + public String toString() { + DateFormat format = new SimpleDateFormat("dd-MM-yyyy"); + format.setLenient(false); + + return artist.getName() + " plays from " + + format.format(startDate.getTime()) + " to " + + format.format(endDate.getTime()) + "."; + } +} diff --git a/Event.java b/Event.java deleted file mode 100644 index 62cf8b4..0000000 --- a/Event.java +++ /dev/null @@ -1,15 +0,0 @@ - -public class Event -{ - private int startTime; - private int endTime; - private Artist artist; - private String description; - private int id; - - public Event() - { - - } - -} diff --git a/GUI b/GUI new file mode 100644 index 0000000..9d2ac44 --- /dev/null +++ b/GUI @@ -0,0 +1,5 @@ + +public class GUI { + + //Leeg +} diff --git a/Panel.java b/Panel.java deleted file mode 100644 index 43fdeae..0000000 --- a/Panel.java +++ /dev/null @@ -1,4 +0,0 @@ -public class Panel extends JPanel -{ - -} diff --git a/README.md b/README.md deleted file mode 100644 index 18f4a66..0000000 --- a/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# FestivalPlanner -Avans - Technische Informatica - Periode 3 - Project Festival Planner - -##Project Leden -* Kenneth van Ewijk -* Remco Sannen -* Wesley de Hek -* Yorick Rommers -* Guus van Dongen - -##Taakverdeling -| Deel | Wie | -| ---------- |-----------| -|Achterliggende code|Guus van Dongen| -|Tijdlijn|Yorick Rommers| -|Window|Kenneth van Ewijk| -|Tabel overzicht|Wesley de Hek| -|Event Details|Remco Sannen| -|Artiest|-| diff --git a/Stage b/Stage new file mode 100644 index 0000000..eae5615 --- /dev/null +++ b/Stage @@ -0,0 +1,49 @@ +import java.io.Serializable; +import java.util.ArrayList; + + +public class Stage implements Serializable { + + private static final long serialVersionUID = 1; + + private ArrayList events; + private String description; + private int ID; + + public Stage(String description, int ID ) + { + this.events = new ArrayList(); + this.description = description; + this.ID = ID; + } + + public Event getEvent(int number) + { + return events.get(number); + } + + public String getDescription() + { + return this.description; + } + + public int getID() + { + return this.ID; + } + + public void setDescription(String description) + { + this.description = description; + } + + public void setID(int ID) + { + this.ID = ID; + } + + public void addEvent(Event event) + { + events.add(event); + } +} diff --git a/Stage.java b/Stage.java deleted file mode 100644 index d58808e..0000000 --- a/Stage.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.ArrayList; - - -public class Stage -{ - private ArrayList performances; - private int expectedPopularity; - private String description; - - public Stage() - { - - } -} diff --git a/testmethode b/testmethode new file mode 100644 index 0000000..0e12545 --- /dev/null +++ b/testmethode @@ -0,0 +1,16 @@ +Eventuele methode om de Arraylisten mee te vullen. + +public void test() + { + Artist artist = new Artist("Paul", "Rock", "null", "description"); + Event e = new Event(2015,2,13,15,0,2015,2,13,16,0,artist,"Description",7, 1); + Stage s = new Stage("Main Stage", 1); + + addArtist(artist); + addEvent(e); + addStage(s); + + saveAll(); + fillAll(); + System.out.println("Saved All Data!"); + }