-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuestion_4.java
301 lines (224 loc) · 7.78 KB
/
Question_4.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
import java.util.ArrayList;
class Administrator {
private int capcity;
private boolean saftey;
private boolean healthy;
public Administrator(int capcity, boolean saftey, boolean healthy) {
this.capcity = capcity;
this.saftey = saftey;
this.healthy = healthy;
}
public Administrator() {
}
public boolean accessVenue(int capacity, boolean saftey, boolean healthy) {
this.capcity = capacity;
this.saftey = saftey;
this.healthy = healthy;
if(capacity > 10000) {
if(saftey && healthy) {
return true;
} else {
return false;
}
}
return true;
}
public void produceMedicalTable() {
if(this.healthy) {
System.out.println("\nMedical Table is all Good.");
} else {
System.out.println("\nMedical Table suggect the Health issues.");
}
}
}
class OverseasAthletes {
public OverseasAthletes() {}
public void applyForVisa(boolean visa) {
if(visa) {
System.out.println("\nCongratulation! Visa is issued");
} else {
System.out.println("\nIt took time to issue visa");
}
}
}
class Athletes extends OverseasAthletes {
private Date birthDate;
private Programme program;
private String athlete_address;
private String athlete_name;
public Athletes (String athlete_name, String athlete_address, Date birthDate, Programme program) {
this.birthDate = birthDate;
this.program = program;
this.athlete_name = athlete_name;
this.athlete_address = athlete_address;
}
public void registerForEvent() {
if(this.athlete_name != "" && this.athlete_name != "") {
System.out.println("\nCongratulations! The athlete has been registered For the event");
} else {
System.out.println("\nSorry! The athlete has not been registered For the event, Information is missing");
}
}
public String getAthlete_address() {
return athlete_address;
}
public void setAthlete_address(String athlete_address) {
this.athlete_address = athlete_address;
}
public String getAthlete_name() {
return athlete_name;
}
public void setAthlete_name(String athlete_name) {
this.athlete_name = athlete_name;
}
@Override
public void applyForVisa(boolean visa) {
super.applyForVisa(visa);
}
@Override
public String toString() {
return "Athletes{" + "athlete name=" + athlete_name + ", athlete address=" + athlete_address + ", birthDate = " + birthDate + ", program = " + program + '}';
}
}
class Programme {
private Date date;
private String time;
private int program_id;
private String program_name;
private String location;
public Programme(int program_id, String program_name, Date date, String time, String location) {
this.program_id = program_id;
this.time = time;
this.location = location;
this.program_name = program_name;
this.date = date;
}
public int getProgram_id() {
return program_id;
}
public void setProgram_id(int program_id) {
this.program_id = program_id;
}
public String getProgram_name() {
return program_name;
}
public void setProgram_name(String program_name) {
this.program_name = program_name;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
@Override
public String toString() {
return "Programme{" + "program id=" + program_id + ", program name=" + program_name + ", date =" + date + ", time =" + time + ", location =" + location + '}';
}
}
class Date {
private int year;
private String month;
private int day;
public Date(String month, int year, int day) {
this.month = month;
this.year = year;
this.day = day;
}
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
@Override
public String toString() {
return "Date{" + "month =" + month + ", year =" + year + ", day =" + day + '}';
}
}
class Organizers {
private boolean isCompleted;
private ArrayList<Programme> programs;
public Organizers(ArrayList<Programme> programs) {
this.programs = programs;
this.programs = new ArrayList<>();
}
public void programCompleted() {
if(this.getIsCompleted()) {
System.out.println("All the Programs are completed ");
} else {
System.out.println("Programs are still remaining");
}
}
public void bookVenue() {
if(this.programs != null) {
System.out.println("Congralutions! The Venue is approved");
} else {
System.out.println("Sorry! The Venue is not approved");
}
}
public void produceSchedule() {
for(Programme p: this.programs) {
p.toString();
}
}
public void produceResults() {
for(int i = 0 ; i < this.programs.size(); i++) {
System.out.println("Position " + i + " goes to " + this.programs.get(i).getProgram_name());
}
}
public void setIsCompleted(boolean isCompleted) {
this.isCompleted = isCompleted;
}
public boolean getIsCompleted() {
return isCompleted;
}
}
class Test {
public static void main(String[] args) {
Date athleteDate = new Date("Feburay", 1993, 5);
Date athlete1Date = new Date("November", 1990, 20);
Date progDate = new Date("May", 2018, 10);
Programme programme = new Programme(2, "Tennis", new Date("March", 2019, 2), "12:00", "MAJU");
Programme programme1 = new Programme(2, "Tennis", new Date("March", 2019, 2), "12:00", "MAJU");
Athletes[] athletes = new Athletes[2];
athletes[0] = new Athletes("Sultan", "Lyari", athleteDate, programme);
athletes[1] = new Athletes("Sania Mirza", "Mumbai", athlete1Date, programme1);
((OverseasAthletes)athletes[1]).applyForVisa(true);
for(int i = 0 ; i < athletes.length ; i++ ) {
System.out.println(athletes[i].toString());
athletes[i].registerForEvent();
}
ArrayList<Programme> programmes = new ArrayList<Programme>();
programmes.add(programme);
programmes.add(programme1);
Administrator admin = new Administrator();
if(admin.accessVenue(15000, true, true)) {
Organizers organize = new Organizers(programmes);
organize.bookVenue();
organize.produceSchedule();
organize.setIsCompleted(true);
organize.programCompleted();
organize.produceResults();
admin.produceMedicalTable();
}
}
}