浏览代码

Fixed display to set times string based on 1 or more times seen

Joe Hendricks 6 年前
父节点
当前提交
56b4503558
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8
    2
      src/main/java/io/zipcoder/ItemParser.java

+ 8
- 2
src/main/java/io/zipcoder/ItemParser.java 查看文件

@@ -8,6 +8,7 @@ public class ItemParser {
8 8
 
9 9
     private Pattern pattern;
10 10
     private Matcher matcher;
11
+    private String setTimes;
11 12
     private int counter = 0;
12 13
     private Main main = new Main();
13 14
     private Map<String, ArrayList<Item>> groceryMap = new HashMap<String, ArrayList<Item>>();
@@ -123,12 +124,17 @@ public class ItemParser {
123 124
             displayBuild.append("\n" +
124 125
                     String.format("%15s%3s%5s", "===============", "\t\t\t", "===============") + "\n");
125 126
 
126
-            ArrayList<Double> uniquePriceList = getUniquePrices(item);
127
+        ArrayList<Double> uniquePriceList = getUniquePrices(item);
127 128
 
128 129
             for (int i = 0; i < uniquePriceList.size(); i++) {
130
+
131
+                if(seenPriceOccurences(item.getValue(), uniquePriceList.get(i)) == 1){
132
+                    setTimes = "   time";
133
+                } else setTimes = "  times";
134
+
129 135
                 displayBuild.append(String.format("%-11s%.2f%15s%2d%5s", "Price:", uniquePriceList.get(i)
130 136
                         , "seen: ", seenPriceOccurences(item.getValue(), uniquePriceList.get(i))
131
-                        , "  times"));
137
+                        , setTimes));
132 138
                 displayBuild.append("\n" +
133 139
                         String.format("%15s%3s%5s", "---------------", "\t\t\t", "---------------") + "\n");
134 140
             }