public Contact findContact (String name){
if(name == null){
throw new IllegalArgumentException("name must not be null");
}
Contact contact = null;
for (int length=this.contacts.size(); length > 0; length--) {
Contact currContact = this.contacts.get((new Random()).nextInt(length));
if(currContact.getName().equals(name)) {
contact = currContact;
break;
}
else {
this.contacts.remove(currContact);
this.contacts.add(currContact);
}
}
return contact;
}
I can think of a way for the for loop to be covered in a test case. Could someone tell me or would I need to post more of my code?
Aucun commentaire:
Enregistrer un commentaire