This repository was archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathDisasterDescription.java
More file actions
113 lines (93 loc) · 2.46 KB
/
DisasterDescription.java
File metadata and controls
113 lines (93 loc) · 2.46 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
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
package codingcompetition2019;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
public class DisasterDescription {
int highest = 0;
String highestYr = "";
String category = "";
public DisasterDescription(List<List<String>> records) {
this.highest = 0;
this.highestYr = "";
for (int i = 0; i < records.size(); i++) {
if ((Integer.parseInt(records.get(i).get(3))) > highest) {
highest = Integer.parseInt(records.get(i).get(3));
highestYr = records.get(i).get(2);
}
}
}
public DisasterDescription(String cat, List<List<String>> records) {
this.highest = 0;
this.highestYr = "";
List<List<String>> newRecords = records;
for (int i = 0; i < newRecords.size(); i++){
if(newRecords.get(i).get(0).contains(cat)) {
continue;
}
else {
newRecords.remove(i);
i--;
}
}
for (int i = 0; i < newRecords.size(); i++) {
if ((Integer.parseInt(newRecords.get(i).get(3))) > highest) {
highest = Integer.parseInt(newRecords.get(i).get(3));
highestYr = newRecords.get(i).get(2);
}
}
}
public DisasterDescription(int no, String year, List<List<String>> records) {
this.highest = 0;
this.highestYr = "";
List<List<String>> newRecords = records;
for (int i = 0; i < newRecords.size(); i++){
if(newRecords.get(i).get(0).contains("All natural disasters")){
newRecords.remove(i);
i--;
}
else if(newRecords.get(i).get(2).contains(year)) {
continue;
}
else {
newRecords.remove(i);
i--;
}
}
for (int i = 0; i < newRecords.size(); i++) {
if ((Integer.parseInt(newRecords.get(i).get(3))) > highest) {
highest = Integer.parseInt(newRecords.get(i).get(3));
category = newRecords.get(i).get(0);
}
}
}
public DisasterDescription(int no, int nono, String cat, List<List<String>> records) {
this.highest = 0;
this.highestYr = "";
List<List<String>> newRecords = records;
for (int i = 0; i < newRecords.size(); i++){
if(newRecords.get(i).get(0).contains("All natural disasters")){
newRecords.remove(i);
i--;
}
else if(newRecords.get(i).get(0).contains(cat)){
continue;
}
else {
newRecords.remove(i);
i--;
}
}
for (int i = 0; i < newRecords.size(); i++) {
highest += Integer.parseInt(newRecords.get(i).get(3));
}
}
public String getYear() {
return highestYr;
}
public String getCategory() {
return category;
}
public int getReportedIncidentsNum() {
return highest;
}
}