Question: A team member submitted the following code for you to review. Identify at least 5 things that would improve the code: package edu.metrostate; import java.util.ArrayList;

A team member submitted the following code for you to review. Identify at least 5 things that would improve the code:

package edu.metrostate;

import java.util.ArrayList;

import java.util.Collections;

public class DriversLicenseRepository extends ArrayList {

public List 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 Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!