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