ber submitted the following code for you to review. Identify at least 5 things that would improve th
A team member submitted the following code for you to review. Identify at least 5 things that would improve the code:
package edu.school;
import java.util.ArrayList;
import java.util.Collections;
public class DriversLicenseRepository extends ArrayList<Object> {
public List<Object> updateExpirationDate(License license, Date temp) {
ArrayList list = new ArrayList();
for(Object v : this) {
if((((License)v.getLicenseNo()) == license.getLicenseNo(){
list.add(v);
}
}
return list;
}
public void recordVote(Ballot ballot, int voter) {
ArrayList newList = new ArrayList<>();
Election election = ElectionManager.getInstance();
for(Object v : this) {
if(((Voter)v.id) == voter) {
election.addVote(ballot, (Voter)v);
}
newList.add(v);
}
clear();
addAll(newList);
}
public Voter getLicense(String i)
throws IllegalArgumentException{
if(get(i) instanceof License) {
return get(0);
}
throw new IllegalArgumentException();
}
}
Step by step
Solved in 2 steps