-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActorFilmTest.java
More file actions
59 lines (47 loc) · 1.65 KB
/
ActorFilmTest.java
File metadata and controls
59 lines (47 loc) · 1.65 KB
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
// Waleed Akhtar
import java.util.ArrayList;
public class ActorFilmTest {
public static void main(String[] args) {
// Actor #1: Jack Nicholson
Actor actor1 = new Actor("Jack Nicholson", "Miami", 74);
Film[] film1 = new Film[3];
film1[0] = new Film("Wolf");
film1[1] = new Film("As good as it Gets");
film1[2] = new Film("One flew Over the Cuckoo's Nest");
actor1.setMyFilms(film1);
for (int i = 0; i < 3; i++) {
System.out.println(film1[i]);
}
// Actor #2: Violante Placido
Actor actor2 = new Actor("Violante Placido", "Bologna", 38);
Film[] film2 = new Film[3];
film2[0] = new Film("The American");
film2[1] = new Film("Ghost Rider Spirit of Vengeance");
film2[2] = new Film("Barah Aanan");
actor2.setMyFilms(film2);
for (int i = 0; i < 3; i++) {
System.out.println(film2[i]);
}
System.out.println('\n');
// Creating an Array list
ArrayList<Actor> actorArray = new ArrayList<>();
actorArray.add(actor1);
actorArray.add(actor2);
// Print
for(int i = 0; i < actorArray.size(); i++){ // For loop goes over the amount of actors added to the array list
System.out.println("Actor Number #" + (i+1));
System.out.println("Name: " + actorArray.get(i).getName());
System.out.println("Address: " + actorArray.get(i).getAddress());
System.out.println("Age: " + actorArray.get(i).getAge());
for(int j = 0; j < 3; j++){
System.out.println(actorArray.get(i).getMyFilms()[j]);
}
}
System.out.println('\n');
// Copy print
Actor actor3 = new Actor(actor2);
actor3.getMyFilms()[0] = new Film("Bambi");
actor3.print();
actor2.print();
}
}