Refactor
This commit is contained in:
parent
5a080e088c
commit
f7d7ce8447
@ -30,8 +30,7 @@ public class CovidDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList <CovidEntry> safeToOpen(String st){
|
public ArrayList <CovidEntry> safeToOpen(String st){
|
||||||
ArrayList<CovidEntry> result = null;
|
ArrayList<CovidEntry> result = new ArrayList<CovidEntry>();
|
||||||
ArrayList<CovidEntry> temp = new ArrayList<CovidEntry>();
|
|
||||||
int match = 0;
|
int match = 0;
|
||||||
int previousDailyInfections = -1;
|
int previousDailyInfections = -1;
|
||||||
|
|
||||||
@ -41,26 +40,21 @@ public class CovidDatabase {
|
|||||||
previousDailyInfections = c.getDailyInfections();
|
previousDailyInfections = c.getDailyInfections();
|
||||||
match += 1;
|
match += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (c.getDailyInfections() < previousDailyInfections) {
|
else if (c.getDailyInfections() < previousDailyInfections) {
|
||||||
match += 1;
|
match += 1;
|
||||||
} else {
|
} else {
|
||||||
match = 1;
|
match = 1;
|
||||||
temp.clear();
|
result.clear();
|
||||||
}
|
}
|
||||||
temp.add(c);
|
result.add(c);
|
||||||
|
|
||||||
previousDailyInfections = c.getDailyInfections();
|
previousDailyInfections = c.getDailyInfections();
|
||||||
}
|
}
|
||||||
if (match == SAFE) {
|
if (match == SAFE) {
|
||||||
result = temp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList <CovidEntry>
|
public ArrayList <CovidEntry>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user