Browse Source

Need's some refactoring... but it works as intended with formatting

Trinh Tong 5 years ago
parent
commit
b482ed3875

+ 2
- 2
src/main/java/io/zipcoder/LeetUtils.java View File

@@ -56,9 +56,9 @@ public class LeetUtils {
56 56
         return (String.format("name: %7s%6sseen: %d " + time, capitalizeMe(name), "", count));
57 57
     }
58 58
 
59
-    public static String stringFormatPrice(Double price, int count) {
59
+    public static String stringFormatPrice(Double price, int count, String label1, String label2) {
60 60
         String time = (count > 1) ? "times" : "time";
61
-        return String.format("%7s%6.2f%5s%7s%d " + time + "\n","Price: ", price,"", "seen: ", count);
61
+        return String.format("%7s%6.2f%5s%7s%d " + time + "\n",label1 + ": ", price,"",label2 + ": ", count);
62 62
     }
63 63
 
64 64
     public static String errorLine(int count) {

+ 1
- 1
src/main/java/io/zipcoder/OutPutObject.java View File

@@ -78,7 +78,7 @@ public class OutPutObject {
78 78
             resultsOutput.append(doubleLine());
79 79
 
80 80
             for (Double d:s.getPrices().getPrices().keySet()) {
81
-                resultsOutput.append(stringFormatPrice(d, s.getPrices().getPrices().get(d)));
81
+                resultsOutput.append(stringFormatPrice(d, s.getPrices().getCount(d), "Price", "seen"));
82 82
                 resultsOutput.append(singleLine());
83 83
             }
84 84
         }