Browse Source

Completed Lab Update

Garrett Arant 6 years ago
parent
commit
4d91dc0b7c

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

@@ -135,7 +135,9 @@ public class ItemParser {
135 135
             Object value = mapEntry.getValue();
136 136
             String time = (1 < (Integer)value) ?  " times": " time";
137 137
             sb.append("Price:   " + keyValue + "\t\t seen: " + value + time + "\n");
138
-            sb.append("-------------\t\t -------------\n");
138
+            if (mapIterator.hasNext()) sb.append(String.format("-------------        -------------\n"));
139
+            if(priceTotals.size() < 2) sb.append(String.format("-------------        -------------\n"));
140
+
139 141
         }
140 142
         return sb.toString();
141 143
     }

+ 6
- 8
src/test/java/io/zipcoder/ItemParserTest.java View File

@@ -133,16 +133,15 @@ public class ItemParserTest {
133 133
         String expected = "name:    Milk\t \t seen: 1 times\n" +
134 134
                 "============= \t \t =============\n" +
135 135
                 "Price:   3.23\t\t seen: 1 time\n" +
136
-                "-------------\t\t -------------\n" +
136
+                "-------------        -------------\n" +
137 137
                 "\n" +
138 138
                 "name:   Bread\t \t seen: 5 times\n" +
139 139
                 "============= \t \t =============\n" +
140 140
                 "Price:   3.23\t\t seen: 2 times\n" +
141
-                "-------------\t\t -------------\n" +
141
+                "-------------        -------------\n" +
142 142
                 "Price:   2.23\t\t seen: 1 time\n" +
143
-                "-------------\t\t -------------\n" +
143
+                "-------------        -------------\n" +
144 144
                 "Price:   1.23\t\t seen: 2 times\n" +
145
-                "-------------\t\t -------------\n" +
146 145
                 "\n" +
147 146
                 "Errors               seen: 0 times";
148 147
         String actual = itemParser.formatText(rawMultipleItems2).toString();
@@ -152,11 +151,10 @@ public class ItemParserTest {
152 151
     @Test
153 152
     public void formatPriceFieldTest() throws ItemParseException {
154 153
         String expected = "Price:   3.23\t\t seen: 2 times\n" +
155
-                "-------------\t\t -------------\n" +
154
+                "-------------        -------------\n" +
156 155
                 "Price:   2.23\t\t seen: 1 time\n" +
157
-                "-------------\t\t -------------\n" +
158
-                "Price:   1.23\t\t seen: 2 times\n" +
159
-                "-------------\t\t -------------\n";
156
+                "-------------        -------------\n" +
157
+                "Price:   1.23\t\t seen: 2 times\n";
160 158
         String actual = itemParser.formatPriceField(rawMultipleItems2, "bread").toString();
161 159
         assertEquals(expected, actual);
162 160
     }