Valka, here is another challenge for you.
Let's take a look.
This is the second part of the previous challenge.
Your task is to display random moves again.
However, this time you need to use a multidimensional array for positive and negative moods.
OK, let me show you now, you ran the program.
It should ask you for a name in the seconds argument.
You also need to pass positive or negative depending on your mood.
Let me show you.
As you can see, each time I ran the program, it displays a positive mood randomly.
Now let's run it by passing a negative argument.
This time, the program displays a negative mood randomly.
Cool, that's OK.
Remember, you need to use multidimensional arrays this time, so do not use single dimensional arrays.
OK, you can find this exercise by following the link in the resources of this lecture.
OK, now please pass the video here and try to solve this challenge.
I'll explain the solution.
Also in this lecture, I'm waiting here.
All right, let's take a look at the solution, OK?
Do you remember this program from the first Moodley challenge?
Now, let's refactor this program to multidimensional errors.
This time, the program expects a movement from the user.
So the total number of arguments should be too, right.
So let's check for that.
Now, let's also add the mood argument to the usage message, positive or negative?
OK, now I'm going to start the mood argument in this mood variable, then I'm going to fetch it from
the second argument.
All right.
Now, using an inner I'm going to group these messages by the mood.
There are three positive and three negative moods.
So I'm going to set the entire area is Lancs to three like this.
Then I need to create two interests.
First, I'm going to create an inner array for the positive moods than for the negative moods.
OK, good.
So here the first inner array contains positive moods and the second inner area contains the negative
moods.
Right.
And the outer muser contains all the increase in this version of the program.
I can only display a random mood message from the inner ears, right.
So I'm going to get the first inner ear length.
I could get it from the second area as well.
Doesn't matter because they all have the same length.
OK, now I need to select an inner ear depending on the mood argument.
To do that, I'm going to declare a variable like this.
MI means mood index.
OK, so if the mood is not positive, then I'm going to assign one to this variable.
This will help me to select the negative moods.
The first inner error contains the positive moods and its variables.
Zero value is already zero, right?
So by default, this variable selects the positive moods already.
Right?
I don't need to do anything for selecting the positive moods.
Now here I'm going to get the mood depending on the index variable like this here.
This first index selects an inner array, depending on the mood argument and the second index selects
a random mood from that area.
All right, OK, let's try it now.
Let's first run it without any arguments like this.
Good.
It displays the usage.
Now, let's try it like this.
Could it only brings positive moods?
Now let's try it with negative mood.
Perfect.
The program works correctly, right?
OK, that's all for now in the next picture, A.