Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,359 --> 00:00:05,590
In the first video, we implemented tasks one, two and three, and we loaded all the contacts into
2
00:00:05,590 --> 00:00:08,980
the contact list except for Geo, because her birthdate isn't valid.
3
00:00:09,700 --> 00:00:14,500
Now on to the final task for part six, which is to create a function named at manage contacts.
4
00:00:15,660 --> 00:00:19,710
We're going to be interacting with the user and managing our contacts through this function.
5
00:00:27,210 --> 00:00:30,270
So I'm going to start by creating a new object of the scanner class.
6
00:00:32,159 --> 00:00:35,190
This scanner object is going to receive input from the system.
7
00:00:35,190 --> 00:00:36,150
System in.
8
00:00:43,660 --> 00:00:46,480
And the Java Dark tells us to create an infinite loop.
9
00:00:46,480 --> 00:00:47,650
So we'll do just that.
10
00:00:48,930 --> 00:00:52,470
And we need to ask the user to add or remove a contact or exit.
11
00:00:52,890 --> 00:00:54,900
I'm just going to copy what we have from the workbook.
12
00:01:05,340 --> 00:01:10,170
And after asking the user for their response, we're going to pick it up using scanned next line.
13
00:01:22,740 --> 00:01:25,250
Kano if their response happens to equal a.
14
00:01:36,980 --> 00:01:41,150
We're going to copy the following from the workbook, which further prompts the user for their name,
15
00:01:41,150 --> 00:01:43,010
phone number and birthdate.
16
00:01:48,860 --> 00:01:51,650
Then we're going to pick up every answer using scanned next line.
17
00:02:23,460 --> 00:02:29,100
And now from the information they provided, we can add a new contacts manager and contacts.
18
00:02:31,530 --> 00:02:33,930
And we'll create a new contact from the name.
19
00:02:36,110 --> 00:02:38,660
Number and birth date that they passed in.
20
00:02:41,110 --> 00:02:42,010
Here, we get an error.
21
00:02:42,040 --> 00:02:45,370
That's because the contact constructor can throw a pass exception.
22
00:02:45,850 --> 00:02:47,980
A pass exception is a checked exception.
23
00:02:47,980 --> 00:02:52,480
So if you want to call this constructor, job is going to force you to try to run the code.
24
00:02:58,310 --> 00:03:01,790
And if the code happens to fail, you need to catch the pirates exception.
25
00:03:09,370 --> 00:03:11,620
And we'll just print the message that comes out of it.
26
00:03:17,350 --> 00:03:17,710
All right.
27
00:03:17,710 --> 00:03:21,930
And after writing the contact, the article tells us to use a finally blocked print.
28
00:03:27,880 --> 00:03:29,080
Updated contact.
29
00:03:45,370 --> 00:03:47,620
Followed by the updated list of contacts.
30
00:03:51,090 --> 00:03:51,900
That's all for case.
31
00:03:52,590 --> 00:03:55,380
If it's case B and they want to remove a contact.
32
00:04:02,870 --> 00:04:05,150
Then we'll just ask them who they'd like to remove.
33
00:04:19,000 --> 00:04:23,530
Then we can call a manager and remove contact and remove whatever name value the user.
34
00:04:23,530 --> 00:04:24,070
Paston.
35
00:04:32,500 --> 00:04:32,960
All right.
36
00:04:32,980 --> 00:04:37,030
And if the user chooses C or anything else, really just break the loop.
37
00:04:41,510 --> 00:04:44,000
And after the wire loop, don't forget to close scatter.
38
00:04:49,560 --> 00:04:53,040
All right, now, back in the main method, we can call manage contacts.
39
00:05:00,090 --> 00:05:00,570
I see that.
40
00:05:00,570 --> 00:05:02,130
I've called that managed contact.
41
00:05:02,160 --> 00:05:03,690
Let me just make sure it's plural.
42
00:05:07,320 --> 00:05:09,150
Think we're now ready to test each case.
43
00:05:21,830 --> 00:05:23,530
I'll start by testing, Casey.
44
00:05:23,600 --> 00:05:25,670
I'll add another contact named Zack.
45
00:05:26,830 --> 00:05:33,880
With a phone number of 111, two, two, two, three, three, three and with a birth date of 12, 12,
46
00:05:33,880 --> 00:05:35,050
1995.
47
00:05:41,650 --> 00:05:43,470
Next thing I'll do is remove a contact.
48
00:05:43,480 --> 00:05:44,500
I'll remove Zack.
49
00:05:48,670 --> 00:05:52,540
And woops, forget the print, the updated contact after removing them.
50
00:06:03,820 --> 00:06:04,510
Let's try it again.
51
00:06:16,190 --> 00:06:19,880
All that dark again with the same phone number as before.
52
00:06:20,120 --> 00:06:21,320
Same birth date.
53
00:06:23,800 --> 00:06:24,670
And get.
54
00:06:33,520 --> 00:06:34,210
Just like that.
55
00:06:34,210 --> 00:06:35,110
Zach has gone.
56
00:06:36,100 --> 00:06:37,210
Finally, I'll just exit.
57
00:06:41,570 --> 00:06:44,300
And that's all for adding interactivity to the application.
58
00:06:45,480 --> 00:06:49,860
If you want to visualize what's going on, feel free to add breakpoints and launch the debugger.
59
00:06:51,520 --> 00:06:52,090
Otherwise.
60
00:06:52,090 --> 00:06:53,540
I hope you're ready for part seven.
61
00:06:53,560 --> 00:06:54,550
I'll see you in there.
5254
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.