From f7d7ce8447e17c736bb337bfa09b817fc4344c0f Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 16 Apr 2021 09:55:59 -0400 Subject: [PATCH] Refactor --- java/final-project/CovidDatabase.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/java/final-project/CovidDatabase.java b/java/final-project/CovidDatabase.java index 5bc919a..60fc273 100644 --- a/java/final-project/CovidDatabase.java +++ b/java/final-project/CovidDatabase.java @@ -30,8 +30,7 @@ public class CovidDatabase { } public ArrayList safeToOpen(String st){ - ArrayList result = null; - ArrayList temp = new ArrayList(); + ArrayList result = new ArrayList(); int match = 0; int previousDailyInfections = -1; @@ -41,26 +40,21 @@ public class CovidDatabase { previousDailyInfections = c.getDailyInfections(); match += 1; } - else if (c.getDailyInfections() < previousDailyInfections) { match += 1; } else { match = 1; - temp.clear(); + result.clear(); } - temp.add(c); + result.add(c); previousDailyInfections = c.getDailyInfections(); } if (match == SAFE) { - result = temp; - break; + return result; } } - - return result; - - + return null; } public ArrayList