-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecord.java
More file actions
127 lines (116 loc) · 3.23 KB
/
Record.java
File metadata and controls
127 lines (116 loc) · 3.23 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package FileManagement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class Record {
public int id;
public String category;
public String descript;
public String dayOfTheWeek;
public String date;
public String time;
public String pdDistrict;
public String resolution;
public String address;
public String transaction;
/**
* Constructor for transaction file fields.
*/
public Record( int id, String category, String descript, String dayOfTheWeek,
String date, String time, String pdDistrict,String resolution,String address,
String transaction)
{
this.id = id;
this.category = category;
this.descript = descript;
this.dayOfTheWeek = dayOfTheWeek;
this.date = date;
this.time = time;
this.pdDistrict = pdDistrict;
this.resolution = resolution;
this.address = address;
this.transaction = transaction;
}
/**
* Constructor for the master file fields.
*/
public Record( int id, String category, String descript, String dayOfTheWeek,
String date, String time, String pdDistrict,String resolution,String address)
{
this.id = id;
this.category = category;
this.descript = descript;
this.dayOfTheWeek = dayOfTheWeek;
this.date = date;
this.time = time;
this.pdDistrict = pdDistrict;
this.resolution = resolution;
this.address = address;
}
/**
* Reads the Category from the array of records and counts the frequency of it.
*
* @param ArrayList<Record>
*
* @return Map<String, Double>
*
*/
public static Map<String, Double> analyze_records_catagory(ArrayList<Record> Records)
{
Map<String, Double> map=new HashMap<String, Double>();
for(Record rec : Records){
if(map.containsKey(rec.category)){
// has category increment value
map.put(rec.category, map.get(rec.category) + 1);
}
else {
map.put(rec.category, (double) 1);
}
}
return map;
}
/**
* Reads the Location value(PDDistrict) from the array of records and counts the frequency of it.
*
* @param ArrayList<Record>
*
* @return Map<String, Double>
*
*/
public static Map<String, Double> analyze_records_catagory_by_district(ArrayList<Record> Records)
{
Map<String, Double> map=new HashMap<String, Double>();
for(Record rec : Records){
if(map.containsKey(rec.pdDistrict)){
// has pdDistrict increment value
map.put(rec.pdDistrict, map.get(rec.pdDistrict) + 1);
}
else {
map.put(rec.pdDistrict, (double) 1);
}
}
return map;
}
/**
* Reads the Resolution value from the array of records and counts the frequency of it.
*
* @param ArrayList<Record>
*
* @return Map<String, Double>
*
*/
public static Map<String, Double> analyze_records_catagory_by_resolution(ArrayList<Record> Records)
{
Map<String, Double> map=new HashMap<String, Double>();
for(Record rec : Records){
if(map.containsKey(rec.resolution)){
// has pdDistrict increment value
map.put(rec.resolution, map.get(rec.resolution) + 1);
}
else {
map.put(rec.resolution, (double) 1);
}
}
return map;
}
}