Przeglądaj źródła

Updated name validation

Trinh Tong 6 lat temu
rodzic
commit
758fb9317b

+ 6
- 1
src/main/java/com/zipcodewilmington/phonebook/PhoneBook.java Wyświetl plik

@@ -37,8 +37,13 @@ public class PhoneBook {
37 37
 
38 38
 
39 39
     public String lookupByName(String lookupName) {
40
+        for (String key: allNames) {
41
+            if (key.equals(lookupName)) {
42
+                return this.phoneList.get(lookupName).toString();
43
+            }
44
+        }
40 45
 
41
-        return this.phoneList.get(lookupName).toString();
46
+        return "Invalid Name.";
42 47
     }
43 48
 
44 49
     public void removeRecord(String nameToRemove) {