Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.ArrayList; import java.util.Arrays; import java.util.NoSuchElementException; public class Contact { private ArrayList contacts; private String contactName; public Contact ( ) { throw new NoSuchElementException (

"import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
public class Contact {
private ArrayList contacts;
private String contactName;
public Contact(){
throw new NoSuchElementException();
}
public Contact(String name){
this.contactName = name;
contacts = new ArrayList<>();
}
public String getName(){
return contactName;
}
public boolean nameMatches(String search){
return contactName.toLowerCase().contains(search);
}
public void addContactInformation(String contactInfo){
contacts.add(contactInfo);
}
public String[] getContactInformation(){
String[] contactsArr = new String[contacts.size()];
for (int i =0; i < contacts.size(); i++){
contactsArr[i]= contacts.get(i);
}
return contactsArr;
}
@Override
public String toString(){
return Arrays.toString(getContactInformation());
}
}
Write a unit test (TestContact.java) that calls each of the methods in your Contact class at least once. For each method call that returns a value, your unit test must do at least one of two things: 1. compare the results of the call to what is expected, then at the end print whether all the results are as expected, or 2. print the result of each method call."PN01

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

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions