1 00:00:00,460 --> 00:00:04,000 The final task for part five is to create a function named manage movies. 2 00:00:04,360 --> 00:00:05,440 It's going to be void. 3 00:00:13,980 --> 00:00:16,710 We'll start by creating a new object of the scanner class. 4 00:00:20,460 --> 00:00:26,220 This scanner object is going to receive input from the system system Dothan and the Java dock tells 5 00:00:26,220 --> 00:00:27,480 us to create an infinite loop. 6 00:00:27,480 --> 00:00:28,320 So we'll do that. 7 00:00:35,570 --> 00:00:39,450 And we need to ask the user if they want to purchase rent return. 8 00:00:39,470 --> 00:00:41,630 So you can just copy the snippet from the article. 9 00:01:00,300 --> 00:01:02,820 And we'll start by picking up the user's response. 10 00:01:02,850 --> 00:01:04,890 String response is equal to scanned. 11 00:01:05,010 --> 00:01:05,640 Next line. 12 00:01:09,360 --> 00:01:13,560 And first, we'll check if the response isn't equal to A, B or C. 13 00:01:32,250 --> 00:01:34,350 Then we're going to close, scatter and break the loop. 14 00:01:40,680 --> 00:01:46,050 If it's one of them, then we're going to ask them to name the movie they want to purchase rent or return. 15 00:01:57,380 --> 00:01:59,900 Well pick up the response with scanned our next line. 16 00:02:04,660 --> 00:02:08,800 And what we do with this movie depends on the user's previous response. 17 00:02:09,310 --> 00:02:14,200 So we're going to make a switch statement that compares the users response against three cases. 18 00:02:16,130 --> 00:02:16,880 Case A. 19 00:02:18,600 --> 00:02:19,290 Casspi. 20 00:02:20,860 --> 00:02:21,700 In Casey. 21 00:02:25,890 --> 00:02:30,960 If it's they just sell them the movie story don't action name sell. 22 00:02:39,110 --> 00:02:42,320 If it's case B, then we're going to rent them the movie. 23 00:02:48,620 --> 00:02:51,470 And if it's Casey, let them return the movie. 24 00:02:59,760 --> 00:03:04,170 And at the end, whatever their option was, we're going to print updated movies. 25 00:03:12,840 --> 00:03:15,720 Followed by all the movies inside the store object. 26 00:03:20,210 --> 00:03:20,900 And that's all. 27 00:03:20,930 --> 00:03:22,940 Now we just got a call, this method from Maine. 28 00:03:38,530 --> 00:03:40,740 First at our other movies to the collection. 29 00:03:40,750 --> 00:03:41,650 Great to begin. 30 00:03:41,650 --> 00:03:42,580 See them all here. 31 00:03:44,090 --> 00:03:45,980 I'm going to start by purchasing a movie. 32 00:03:48,770 --> 00:03:49,610 And you know what? 33 00:03:49,640 --> 00:03:51,500 I want to make sure this happened in one line. 34 00:04:00,970 --> 00:04:01,380 Kay. 35 00:04:01,420 --> 00:04:02,470 Whenever we run the code. 36 00:04:13,940 --> 00:04:15,740 I'll purchase The Dark Knight. 37 00:04:22,220 --> 00:04:24,020 And it sells me The Dark Knight. 38 00:04:24,410 --> 00:04:26,450 And you can tell it's been removed from the store. 39 00:04:35,070 --> 00:04:37,290 Now I'm going to rent Pulp Fiction. 40 00:04:48,110 --> 00:04:49,670 Then I'll return Pulp Fiction. 41 00:04:53,890 --> 00:04:55,390 And this works perfectly. 42 00:04:56,200 --> 00:04:58,540 Now I can just type anything to exit the loop. 43 00:05:00,420 --> 00:05:01,150 And that's all. 44 00:05:01,200 --> 00:05:03,180 We finished building our application. 45 00:05:03,510 --> 00:05:07,650 The next step is to make a bulletproof, and we're going to do that in part six. 46 00:05:08,370 --> 00:05:09,690 I will see you in there.