Changed contactCounter.
This now gives 0 as the first id. This means that each contact id matches their index number in the ArrayList.
Added method to find one contact.
The contact is returned as part of a set. I still need to add code to make it return multiple contacts, ensure no duplicates, and deal with ids that don't exist.
Added tests and changed buildUp method.
1. Made the buildup method create 5 contacts and add them to a list.
2. Added test to ensure that a single existing contact is returned.
3. Added start of a test to ensure that multiple existing contacts are returned.
getContacts can now handle multiple ids, including duds.
If id is given for a non-existent contact the code throws IllegalArgExcp. I also made the NullPExcep in the addNewContact method supply an error msg with the exception.
I don't know how the code will respond to duplicate IDs. That's next...
Added test for getting non existent contact.
Should throw illegArgExcep.
Added test to check handling of duplicate IDs.
The HashSet (correctly) ignores duplicate IDs.
Added addNotes method.
Made it put a newline between each call to this method.
Added tests for adding new notes.
New notes, including null, should be added without problem.
Removed useless test.
It was testing that ID != 0, but was in the wrong place (i.e. should have been first test in the list. Anyway, I now make the first contact get an ID of 0 to match the ArrayList index.
Added getContacts method that searches on strings.
The method finds string matches in a contact's "name" field (exact or substring matches). If nothing is found an emtpy string is returned.
Added test for finding contacts based on search string.
Test for exact match, substring match, no match.
Added test for empty and null search strings.
Added exception handling for null search term.
I decided to treat an empty string as if it were a null string. Both throw a NullPointerExcep.