From 7bc43d82499f2e92619e62942bc75c225e90e40a Mon Sep 17 00:00:00 2001 From: Aaron Sun Date: Sun, 25 Oct 2020 16:15:42 -0700 Subject: [PATCH] Simplified a section of code for total price by store (used HashMap to access header section) --- Listify/app/src/main/java/com/example/listify/ListPage.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Listify/app/src/main/java/com/example/listify/ListPage.java b/Listify/app/src/main/java/com/example/listify/ListPage.java index a45e323..a7a3e89 100644 --- a/Listify/app/src/main/java/com/example/listify/ListPage.java +++ b/Listify/app/src/main/java/com/example/listify/ListPage.java @@ -100,11 +100,7 @@ public class ListPage extends AppCompatActivity { pListItemPair.add(entry); } else { - int index = 0; - - while(index < pNames.size() && !pNames.get(index).equals("Kroger")) { - index++; - } + int index = storeHeaderIndex.get("Kroger"); totalPriceByStore.put("Kroger", totalPriceByStore.get("Kroger") + (item.getPrice().doubleValue() * entry.getQuantity())); pPrices.set(index, totalPriceByStore.get("Kroger").toString());