-
Notifications
You must be signed in to change notification settings - Fork 49
/
FilmMain.java
89 lines (76 loc) · 2.43 KB
/
FilmMain.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
87
88
89
/*
* Create a class Film with string objects which stores name, language and lead_actor and
* category (action/drama/fiction/comedy). Also include an integer data member that stores the
* duration of the film. Include parameterized constructor, default constructor and accessory
* functions to film class. Film objects can be initialized either using a constructor or accessor functions.
*/
import java.util.Vector;
class Film {
String name;
String language;
String lead_actor;
String category;
int duration;
Film() {
name = null;
language = null;
lead_actor = null;
category = null;
duration = 0;
}
Film(String n, String lang, String actor, String cat, int dur) {
name = n;
language = lang;
lead_actor = actor;
category = cat;
duration = dur;
}
}
public class FilmMain {
public static void main(String[] args) {
Film films;
Vector<Film> Films = new Vector<Film>();
films = new Film();
films.name = "Terminator";
films.language = "English";
films.lead_actor = "Arnold";
films.duration = 10;
films.category = "Action";
Films.add(films);
films = new Film();
films.name = "Terminator 2";
films.language = "English";
films.lead_actor = "Arnold";
films.duration = 20;
films.category = "Action";
Films.add(films);
films = new Film();
films.name = "Robot 1";
films.language = "Tamil";
films.lead_actor = "Rajini";
films.duration = 10;
films.category = "Comedy";
Films.add(films);
films = new Film();
films.name = "Robot 2";
films.language = "Tamil";
films.lead_actor = "Rajini";
films.duration = 30;
films.category = "Comedy";
Films.add(films);
int min = 9999999;
int imin = 0;
for (int i = 0; i < 4; i++) {
films = Films.get(i);
if (films.lead_actor.equals("Arnold"))
if (films.duration < min) {
min = films.duration;
imin = i;
}
if (films.category.equals("Comedy"))
System.out.println(films.name + " is a Comedy movie");
}
films = Films.get(imin);
System.out.println("Shortest Arnold film is " + films.name + " and duration: " + min);
}
}