WEBVTT 00:00.560 --> 00:03.320 Valka, here is another challenge for you. 00:03.860 --> 00:04.640 Let's take a look. 00:05.360 --> 00:07.940 This is the second part of the previous challenge. 00:08.810 --> 00:11.580 Your task is to display random moves again. 00:12.170 --> 00:17.900 However, this time you need to use a multidimensional array for positive and negative moods. 00:17.940 --> 00:21.590 OK, let me show you now, you ran the program. 00:21.950 --> 00:25.250 It should ask you for a name in the seconds argument. 00:25.280 --> 00:29.670 You also need to pass positive or negative depending on your mood. 00:29.960 --> 00:30.620 Let me show you. 00:34.700 --> 00:39.810 As you can see, each time I ran the program, it displays a positive mood randomly. 00:40.460 --> 00:43.540 Now let's run it by passing a negative argument. 00:44.150 --> 00:47.540 This time, the program displays a negative mood randomly. 00:48.440 --> 00:49.850 Cool, that's OK. 00:50.090 --> 00:57.620 Remember, you need to use multidimensional arrays this time, so do not use single dimensional arrays. 00:57.680 --> 01:03.020 OK, you can find this exercise by following the link in the resources of this lecture. 01:03.740 --> 01:08.210 OK, now please pass the video here and try to solve this challenge. 01:08.750 --> 01:10.300 I'll explain the solution. 01:10.340 --> 01:13.070 Also in this lecture, I'm waiting here. 01:18.320 --> 01:21.400 All right, let's take a look at the solution, OK? 01:21.680 --> 01:25.220 Do you remember this program from the first Moodley challenge? 01:26.210 --> 01:30.150 Now, let's refactor this program to multidimensional errors. 01:30.590 --> 01:34.520 This time, the program expects a movement from the user. 01:35.060 --> 01:38.310 So the total number of arguments should be too, right. 01:38.780 --> 01:40.010 So let's check for that. 01:41.020 --> 01:47.140 Now, let's also add the mood argument to the usage message, positive or negative? 01:47.440 --> 01:53.650 OK, now I'm going to start the mood argument in this mood variable, then I'm going to fetch it from 01:53.650 --> 01:54.700 the second argument. 01:55.070 --> 01:55.570 All right. 01:56.410 --> 02:00.040 Now, using an inner I'm going to group these messages by the mood. 02:00.800 --> 02:03.580 There are three positive and three negative moods. 02:04.030 --> 02:07.900 So I'm going to set the entire area is Lancs to three like this. 02:08.170 --> 02:10.450 Then I need to create two interests. 02:10.810 --> 02:16.180 First, I'm going to create an inner array for the positive moods than for the negative moods. 02:16.960 --> 02:17.720 OK, good. 02:18.400 --> 02:25.780 So here the first inner array contains positive moods and the second inner area contains the negative 02:25.780 --> 02:26.200 moods. 02:26.350 --> 02:26.800 Right. 02:27.730 --> 02:34.520 And the outer muser contains all the increase in this version of the program. 02:34.840 --> 02:39.350 I can only display a random mood message from the inner ears, right. 02:39.940 --> 02:42.610 So I'm going to get the first inner ear length. 02:43.240 --> 02:45.830 I could get it from the second area as well. 02:46.130 --> 02:49.180 Doesn't matter because they all have the same length. 02:49.910 --> 02:55.350 OK, now I need to select an inner ear depending on the mood argument. 02:56.110 --> 02:59.140 To do that, I'm going to declare a variable like this. 02:59.980 --> 03:02.080 MI means mood index. 03:02.110 --> 03:07.600 OK, so if the mood is not positive, then I'm going to assign one to this variable. 03:08.350 --> 03:11.140 This will help me to select the negative moods. 03:11.740 --> 03:16.150 The first inner error contains the positive moods and its variables. 03:16.150 --> 03:18.710 Zero value is already zero, right? 03:18.970 --> 03:23.790 So by default, this variable selects the positive moods already. 03:24.190 --> 03:24.560 Right? 03:25.390 --> 03:28.790 I don't need to do anything for selecting the positive moods. 03:29.590 --> 03:35.370 Now here I'm going to get the mood depending on the index variable like this here. 03:35.380 --> 03:42.250 This first index selects an inner array, depending on the mood argument and the second index selects 03:42.250 --> 03:43.970 a random mood from that area. 03:44.440 --> 03:46.690 All right, OK, let's try it now. 03:46.870 --> 03:50.380 Let's first run it without any arguments like this. 03:51.190 --> 03:51.570 Good. 03:51.730 --> 03:53.030 It displays the usage. 03:53.590 --> 03:55.300 Now, let's try it like this. 03:58.500 --> 04:00.780 Could it only brings positive moods? 04:01.350 --> 04:03.660 Now let's try it with negative mood. 04:06.190 --> 04:06.690 Perfect. 04:07.120 --> 04:09.250 The program works correctly, right? 04:10.660 --> 04:14.300 OK, that's all for now in the next picture, A.