|
@@ -8,8 +8,7 @@ import java.util.*;
|
8
|
8
|
import java.util.regex.Matcher;
|
9
|
9
|
import java.util.regex.Pattern;
|
10
|
10
|
|
11
|
|
-import static io.zipcoder.LeetUtils.capitalizeMe;
|
12
|
|
-import static io.zipcoder.LeetUtils.fullManipulate;
|
|
11
|
+import static io.zipcoder.LeetUtils.*;
|
13
|
12
|
|
14
|
13
|
public class ItemParser {
|
15
|
14
|
|
|
@@ -69,7 +68,6 @@ public class ItemParser {
|
69
|
68
|
}
|
70
|
69
|
|
71
|
70
|
|
72
|
|
-
|
73
|
71
|
public void printToFile(String fileName, String rawItemData) throws FileNotFoundException, ItemParseException {
|
74
|
72
|
// Output to file
|
75
|
73
|
ArrayList<String> allItemsRaw = parseRawDataIntoStringArray(rawItemData);
|
|
@@ -96,13 +94,20 @@ public class ItemParser {
|
96
|
94
|
resultsOutput.append("Tariq's Messed up Grocery List...\n\n");
|
97
|
95
|
|
98
|
96
|
for (SameItems s : itemCounters.values()) {
|
99
|
|
- resultsOutput.append(String.format("name: %8s seen: %d", capitalizeMe(s.getName()), s.getCount()));
|
100
|
|
-// resultsOutput.append(String.format("%s %s", item.getName(), item.getPrice()));
|
|
97
|
+ resultsOutput.append(stringFormatName(s.getName(), s.getCount()));
|
|
98
|
+ resultsOutput.append(doubleLine());
|
|
99
|
+
|
|
100
|
+ for (Double d:s.getPrices().getPrices().keySet()) {
|
|
101
|
+ resultsOutput.append(stringFormatPrice(d, s.getPrices().getPrices().get(d)));
|
|
102
|
+ resultsOutput.append(singleLine());
|
|
103
|
+ }
|
101
|
104
|
}
|
|
105
|
+ resultsOutput.append(errorLine(errors));
|
102
|
106
|
System.out.println(resultsOutput.toString());
|
103
|
107
|
}
|
104
|
108
|
|
105
|
|
- public HashMap<String, SameItems> sameItemCounter(ArrayList<Item> allItems) {
|
|
109
|
+
|
|
110
|
+ private HashMap<String, SameItems> sameItemCounter(ArrayList<Item> allItems) {
|
106
|
111
|
|
107
|
112
|
HashMap<String, SameItems> itemCounters = new HashMap<>();
|
108
|
113
|
for (Item i: allItems) {
|
|
@@ -119,7 +124,6 @@ public class ItemParser {
|
119
|
124
|
itemCounters.put(i.getName(),temp);
|
120
|
125
|
}
|
121
|
126
|
}
|
122
|
|
-
|
123
|
127
|
return itemCounters;
|
124
|
128
|
}
|
125
|
129
|
|