1 00:00:00,640 --> 00:00:03,950 Okay, so now that we can add contacts and print them out, let's go ahead and 2 00:00:03,950 --> 00:00:05,680 add the ability to search. 3 00:00:07,040 --> 00:00:14,185 So, first we'll add that as a prompt on the menu, we'll say Search. 4 00:00:15,905 --> 00:00:18,575 And this is going to be pretty easy. 5 00:00:18,575 --> 00:00:21,155 We just add another menu option in our case statement. 6 00:00:22,935 --> 00:00:27,018 So when it is the letter s. 7 00:00:27,018 --> 00:00:30,925 We'll just say enter your search term. 8 00:00:33,585 --> 00:00:37,925 And then we will grab that from standard input. 9 00:00:37,925 --> 00:00:43,088 And now, we've got all of the different methods that we wrote earlier, 10 00:00:43,088 --> 00:00:44,535 to find something. 11 00:00:44,535 --> 00:00:48,800 So we've got, find my name, find by phone number, and find by address. 12 00:00:48,800 --> 00:00:54,430 So, since those are already working, let's go ahead and just call those terms. 13 00:00:54,430 --> 00:00:57,700 With this search variable that we just got from standard input. 14 00:01:02,130 --> 00:01:06,530 And there we go, and actually at the end of this, okay, we've got a new line. 15 00:01:06,530 --> 00:01:07,030 Perfect. 16 00:01:08,270 --> 00:01:11,860 So all we're gonna do, we get this search query from the user, 17 00:01:11,860 --> 00:01:13,600 and then we call our methods with it. 18 00:01:14,920 --> 00:01:17,520 And that's it, we already wrote the methods earlier. 19 00:01:17,520 --> 00:01:19,760 So we're just gonna be calling them here. 20 00:01:19,760 --> 00:01:24,480 Now, we could get more fancy with it and add each of these as a menu option. 21 00:01:24,480 --> 00:01:29,340 But I'm just going to assume that when we want to search our contact list, 22 00:01:29,340 --> 00:01:30,950 we're gonna look through every field. 23 00:01:30,950 --> 00:01:37,190 So, now let's go down to the console and see how it works. 24 00:01:40,210 --> 00:01:42,760 Now first let's add a contact to make sure it works. 25 00:01:42,760 --> 00:01:44,520 Jason Seifer. 26 00:01:45,760 --> 00:01:49,645 Now add a phone number to my home phone number. 27 00:01:49,645 --> 00:01:52,681 123-456-7890. 28 00:01:52,681 --> 00:01:55,116 And then the other key to go back. 29 00:01:55,116 --> 00:01:56,570 Add another contact. 30 00:01:56,570 --> 00:02:01,099 Nick Avery Pettit. 31 00:02:01,099 --> 00:02:03,440 Now add an address. 32 00:02:03,440 --> 00:02:04,433 Work address. 33 00:02:13,030 --> 00:02:14,220 Okay, now let's try searching. 34 00:02:15,400 --> 00:02:17,350 So, let's try searching for Nick. 35 00:02:19,440 --> 00:02:21,610 All right, search results for Nick. 36 00:02:21,610 --> 00:02:22,990 Here's Nick Avery Pettit. 37 00:02:24,040 --> 00:02:27,810 No phone search results and no address search results. 38 00:02:27,810 --> 00:02:30,703 Let's try searching again, search term is 2. 39 00:02:32,431 --> 00:02:39,008 And it looks like I came up, Jason Seifer because my phone number has 2 in it. 40 00:02:39,008 --> 00:02:42,530 And Nick came up, because the address has a two in it. 41 00:02:42,530 --> 00:02:43,040 Okay. 42 00:02:43,040 --> 00:02:43,870 That's great. 43 00:02:43,870 --> 00:02:45,110 In our next video, 44 00:02:45,110 --> 00:02:49,500 we're going to see how to persist the address book in between sessions.