Question: Assignment 5: Utility Methods This assignment will be building on to the prior assignment and will utilize the same Eclipse project. Please refer to assignment

Assignment 5: Utility Methods

This assignment will be building on to the prior assignment and will utilize the same Eclipse project. Please refer to assignment 3 if you need assistance downloading the project template and understanding the existing architecture that you will contribute to.

Please code this in Java using Eclipse.

For this assignment well be creating a new class called, Utilities. The Utilities class will contain two methods; removeDuplicates and linearSearch.

Task 1 Utilities

Package: edu.institution.actions.asn5

Class: Utilities

Create a class called Utilities and create these two methods.

public class Utilities {

public void removeDuplicates(List items){

}

public E linearSearch(List list, E key){

return null;

}

}

Method: removeDuplicates

public void removeDuplicates(List items)

This method excepts a list of items and removes the duplicates from the list. After this method completes, the supplied list should not contain any duplicate items.

For example:

List numbers = new ArrayList<>();

numbers.add("one");

numbers.add("two");

numbers.add("one");

Utilities utilities = new Utilities();

utilities.removeDuplicates(numbers);

// the numbers list should contain two records; one and two

List numbers = new ArrayList<>();

numbers.add(1);

numbers.add(1);

numbers.add(1);

Utilities utilities = new Utilities();

utilities.removeDuplicates(numbers);

// the numbers list should contain one record; 1.

Method: linearSearch

public E linearSearch(List list, E key)

Implement a generic method to do a linear search. Your linear search method should accept a list containing a generic type and a key record to search for in the generic list. Your linear search should return the record associated with the supplied key or null if the key does not exist in the supplied list.

JUnit Tests

Write enough JUnit tests to achieve 100% test coverage and think carefully about your tests. At a minimum, you need to include a unit test that uses an array of Integers, an array of Strings, and an array of LinkedInUsers. You should also test any unusual cases you can think of: What if the ArrayList is empty?

What if it contains only one item?

What if your removeDuplicates method is passed an ArrayList in which every item is identical?

What if the arguments to the two methods are null?

And so on.

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 Databases Questions!