-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
86 lines (77 loc) · 3.53 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import java.io.FileNotFoundException;
import java.text.ParseException;
import java.util.ArrayList;
import videolibrary.*;
public class Main {
public static void main(String args[]) throws FileNotFoundException, ParseException {
TopLevelDemo.teste();
//inicializa arraylists
ArrayList<Media> mediaList = new ArrayList<Media>();
ArrayList<Person> personList = new ArrayList<Person>();
//leitura dos arquivos de dados
personList = IOManager.readPerson(personList);
mediaList = IOManager.readMedia(mediaList, personList);
//realiza uma copia de todos os episodios ou filmes na mediaList
ArrayList<Media> copyMedia = new ArrayList<Media>();
for(Media aux : mediaList){
if(aux instanceof Movie){
copyMedia.add(new Movie((Movie)aux));
}
else if(aux instanceof Serie){
Serie auxSerie = (Serie)aux;
for(int i = 0; i < auxSerie.getNSeasons(); i++){
for(int j = 0; j < auxSerie.getNEpisodesSeason(i); j++){
copyMedia.add(new Episode(auxSerie.GetEpisode(i, j)));
}
}
}
}
//imprime os filmes ou episodios copiados anteriormente
printCopy(copyMedia);
//imprime dados lidos
IOManager.printMedia(mediaList);
IOManager.printPerson(personList);
}
private static void printCopy(ArrayList<Media> mediaList){
for (Media aux : mediaList) {
if (aux instanceof Movie) {
System.out.println("Copied Movie Name: " + aux.GetName());
if (aux.GetGenres() == null)
System.out.println("Copied Genre: Não foi passado nenhum gênero");
else {
for (Util.genresEnum Genre : aux.GetGenres()) {
System.out.println("Copied Genre: " + Genre);
}
}
System.out.println("Copied Movie director: "+ ((Movie)aux).GetDirector().GetName());
if(((Movie)aux).GetActors() != null){
for (int i = 0; i < ((Movie)aux).GetActors().size(); i++){
System.out.println("Copied Movie actor: "+ ((Movie)aux).GetActors().get(i).GetName());
}
}
else{ System.out.println("Copied Movie don't have actors assigned!");}
}
else if (aux instanceof Episode) {
System.out.println("Copied Episode Name: " + aux.GetName());
if (aux.GetGenres() == null)
System.out.println("Copied Genre: Não foi passado nenhum gênero");
else {
for (Util.genresEnum Genre : aux.GetGenres()) {
System.out.println("Copied Genre: " + Genre);
}
}
System.out.println("Copied Episode director: "+ ((Episode)aux).GetDirector().GetName());
if(((Episode)aux).GetActors() != null){
for (int i = 0; i < ((Episode)aux).GetActors().size(); i++){
System.out.println("Copied Episode actor: "+ ((Episode)aux).GetActors().get(i).GetName());
}
}
else{ System.out.println("Copied Episode don't have actors assigned!");}
}
else {
System.out.println("INVALID INSTANCE");
}
System.out.println("");
}
}
}