Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions