-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClothingTaxReport.java
More file actions
55 lines (43 loc) · 1.85 KB
/
Copy pathClothingTaxReport.java
File metadata and controls
55 lines (43 loc) · 1.85 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
import java.lang.String;
import java.util.HashMap;
import java.util.Map;
public class ClothingTaxReport {
HashMap<String, LibraryItem> libraryItemsBySku;
LibraryCSVReader libraryReader;
HashMap<String, LibraryItem> taxedClothing;
public ClothingTaxReport(String catalogFilename, String pathString) {
libraryReader = new LibraryCSVReader(catalogFilename, pathString);
libraryItemsBySku = libraryReader.getItemsBySku();
System.out.println("Found "+libraryItemsBySku.size()+" in "+catalogFilename);
taxedClothing = new HashMap<String, LibraryItem>();
}
public void identifyTaxedClothing() {
for (Map.Entry<String, LibraryItem> entry : libraryItemsBySku.entrySet()){
LibraryItem item = entry.getValue();
String skuString = entry.getKey();
if ((item.getCategory().equals("CLOTHING")) && (item.getTax().equals("Y"))) {
taxedClothing.put(skuString, item);
}
}
System.out.println("Total number of taxed clothing items: "+taxedClothing.size());
}
public void writeReport() {
String[] header = libraryReader.getHeader();
String filename = libraryReader.getFilenameString();
String pathString = libraryReader.getPathString();
LibraryCSVWriter writer = new LibraryCSVWriter(header, filename, pathString);
writer.writeFile(taxedClothing);
}
public static void main(String[] args) {
if (args.length != 2) {
System.err.println("Usage: ItemCountsMerge LibraryCatalogFilename LibraryCatalogPath");
System.exit(1);
}
for(int i = 0; i< args.length; i++) {
System.out.println(String.format("Command Line Argument %d is %s", i, args[i]));
}
ClothingTaxReport report = new ClothingTaxReport(args[0], args[1]);
report.identifyTaxedClothing();
report.writeReport();
}
}