Bladeren bron

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

Joe Hendricks 6 jaren geleden
bovenliggende
commit
56b4503558
1 gewijzigde bestanden met toevoegingen van 8 en 2 verwijderingen
  1. 8
    2
      src/main/java/io/zipcoder/ItemParser.java

+ 8
- 2
src/main/java/io/zipcoder/ItemParser.java Bestand weergeven

@@ -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
             }