In the previous video, we learned one way of programming the <i>joue</i> method, whose job is to check whether a column indicated by the player is a legal play and if so, to put the chip into the grid. In this video, I suggest 2 ways of programming this <i>joue</i> method. Let's start with the header of the <i>joue</i> method. Clearly, if we want to change the algorithm, the body of the method, the header will remain the same. And so I will remind you that we take a grid, an array of integers, which is the game in which we want to play. Then an integer which indicates in which column the player wants to play. And finally a third integer argument, which indicates the color of the chip played in the column. The <i>joue</i> method returns a boolean, which returns <i>true</i> if the play is legal, and <i>false</i> if the play is illegal. Let's change the algorithm from the last version of the <i>joue</i> method and let's start by testing the legality of the play. The play is only legal if the cell at position 0, at the row 0, is not occupied. Indeed, if the cell located at position 0 in the column in which we want to play is not empty, this means that there were chips below and that the column is full. So, as usual, we will start by writing the comment which explains what we will do. If the column is full, then the play is illegal. And now, let's write it in Java. If the column is full, that is, if the grid, at position 0 and in the column we were given is not empty, in other words, is not equal to the predefined value for <i>vide</i> (TN: <i>empty</i>), then the play is illegal and we simply have to leave the method by returning <i>false</i>. This simplifies exploration of the grid greatly to place the chip, since at this point, either we left with <i>false</i>, or we know that the column is not full and so we will necessarily find an empty cell which we can now start to look for. As usual, we put this into a comment, we will search the column from bottom to top to find the first empty cell. This is written in Java thus: we start by naming a variable here, <i>ligne</i> (TN: <i>row</i>) to search the different rows. We initialize this line to the last line of the array, which is <i>size of grid -1 </i>. I remind you that arrays have indices that go from 0 to size-1. So, we initialize <i>ligne</i> to <i>size of grid - 1</i> and then we will search this array upwards. So, while the cell at the position of the current line and the indicated column is not empty, we decrement the line number, so <i>--ligne</i>. Now, we have found an empty cell and we simply have to play there. As always, we write the comment, so we write that <i>grille</i> (TN : <i>grid</i>), at position <i>row, column</i> receives the color which we wish to play. So the first parameter we received, <i>couleur</i>. And we can end by returning the information that we were able to play, by returning <i>true</i>. This is our new version of the <i>joue</i> method. and I will let you appreciate the difference in size of these two methods, disregarding the size of the comments. Let's end with yet another version of the <i>joue</i> method which, this time, builds upon the method from the previous video and improves it. So, here is the version from the previous video and the idea is to use this <i>pleine</i> (TN: <i>occupied</i>) boolean and to try to do things differently. So we will delete it, but with what will we replace it? Let's go back to the initial problem, and I will remind you that we had introduced this <i>pleine</i> boolean because we decremented the row in the first version, until it reached the position 0. So when <i>ligne</i> was null, we continued, in the first version, to decrement and thus to exceed the bounds of the array. All we have to do now is to write this and to say that we want to stop when <i>ligne</i> equals 0. We want to continue as long as <i>ligne</i> is bigger than or equals 0. As soon as the row reaches 0, we want to loop to stop. So we write this, while <i>ligne</i> >= 0. 0, of course, must be considered, as long as <i>ligne</i> is bigger than or equals to 0. So we can continue removing all instances of <i>pleine</i>. There, this simplifies our loop considerably. And we will do the same thing in the last part, at the bottom, were we play, and we will put the test here too, the same one. Namely "if <i>ligne</i> >= 0", indeed, at this point, the row is bigger than or equals 0, it means that we are still within the grid and that we can play. Otherwise, we are outside of the grid. Here is then the final version, with comments of course, which we do not hesitate to add to make our code more legible. This ends our third version of the <i>joue</i> method. That said, there is still a potential error in all our versions of the <i>joue</i> method. Do you see what it might be? I will let you implement this correction as an exercise in the version of <i>joue</i> which you choose to code. At this stage, you should have a decent Java program where you can represent a game, that is, a grid, and the colors of the two players' chips. You can thus initialize this game and display it. And you can play with chips and test the legality of plays in the grid. To have a complete game, we still have to ask a player where he wishes to play and to be able to alternate between players: ask red to play, then yellow. And finally to check whether the game has ended, that is, if one of the players has one or if the grid is full. This will be discussed in the next videos.