1 00:00:05,810 --> 00:00:06,410 Hey everyone. 2 00:00:06,980 --> 00:00:10,860 So then we have created the buttons and just the working gift. 3 00:00:10,880 --> 00:00:14,770 So how we can make them vote like this one basic way. 4 00:00:14,990 --> 00:00:17,170 So for that one I'm adding a come on here. 5 00:00:19,970 --> 00:00:23,740 That is going to be C or double and me and D. 6 00:00:23,750 --> 00:00:34,230 And now we are adding something like show underscore symbol and X and Y relative to to win this one. 7 00:00:34,240 --> 00:00:41,890 Anita now we need to define that function so define show underscore symbol. 8 00:00:42,810 --> 00:00:44,940 And with X and Y. 9 00:00:45,210 --> 00:00:49,780 So what we do here right now is first we will provide this symbol. 10 00:00:50,070 --> 00:00:56,640 All the symbols that we have created to all the buttons the button that we have created and then we 11 00:00:56,640 --> 00:01:00,720 will check whether this symbol are equal or not. 12 00:01:00,720 --> 00:01:07,300 Now one thing I'm again and again think symbol and they are actually text. 13 00:01:07,350 --> 00:01:09,840 So I need to add here next. 14 00:01:09,840 --> 00:01:12,550 So first of all I will take to global variables. 15 00:01:12,810 --> 00:01:14,400 That is a first. 16 00:01:15,090 --> 00:01:22,560 And do more here that is previous x and previous y the same that we have taken there in the initial 17 00:01:22,560 --> 00:01:23,660 condition. 18 00:01:23,670 --> 00:01:26,150 Now we are going to apply this again. 19 00:01:26,160 --> 00:01:29,560 This one is just whether it is the first card or not. 20 00:01:29,580 --> 00:01:33,540 And these two if there is a first card then there are the coordinates of that one. 21 00:01:34,890 --> 00:01:42,190 So now I will provide every button to symbol sorry every button symbol. 22 00:01:42,990 --> 00:01:49,440 So I will take buttons my library sorted my dictionary that containing all the buttons that I have created. 23 00:01:49,680 --> 00:01:53,480 And the button symbol is containing all these symbols that I shuffle randomly. 24 00:01:53,970 --> 00:01:55,050 So what will I do here. 25 00:01:55,440 --> 00:02:04,180 I will write buttons and first access X and fly so in this way I'm accessing every each of the button. 26 00:02:04,360 --> 00:02:10,330 Now to access is text I was a straight again square brackets and in them text. 27 00:02:10,590 --> 00:02:16,770 This is how I can access the text on button and make them equal to here. 28 00:02:16,780 --> 00:02:24,400 Now you need to pass symbols so buttons symbols and the symbol with every particular accent by I'm getting 29 00:02:25,000 --> 00:02:33,670 because I am making symbols pop again and again whenever I am making X invite so for each value of x 30 00:02:33,670 --> 00:02:36,140 and y I'm hoping something. 31 00:02:36,160 --> 00:02:44,130 So that's how I can add this symbol to any button no symbols are added one more come on. 32 00:02:44,140 --> 00:02:54,790 You need to add here X and Vi and their bus update underscored ideal tests. 33 00:02:55,350 --> 00:03:03,480 So this one just updated dusk so David now we are done with creating the buttons with their particular 34 00:03:03,480 --> 00:03:04,710 symbols. 35 00:03:04,710 --> 00:03:05,570 What after that. 36 00:03:06,280 --> 00:03:14,760 Now a second problem here is if they match then developments in and if they don't then again flip or 37 00:03:15,300 --> 00:03:18,590 not what the Flipboard here I'm referring to. 38 00:03:18,600 --> 00:03:24,330 So basically the flip or I'm here traveling to is just like if remember the caterpillar how the game 39 00:03:24,330 --> 00:03:25,390 will be game over. 40 00:03:25,870 --> 00:03:31,470 I remove the caterpillars or the leaves I just change the color with the same like background. 41 00:03:31,500 --> 00:03:34,260 Now flipping means I will just remove the dust. 42 00:03:34,290 --> 00:03:38,020 Sorry to text and then David in the thing. 43 00:03:38,030 --> 00:03:46,870 So it seems like for people so that so I can flip the buttons old state God's so let's begin the deadman. 44 00:03:46,900 --> 00:03:54,010 One more thing before that one we need to make sure that whether there's a first card already flipped 45 00:03:54,010 --> 00:03:56,380 over or this is the first card. 46 00:03:57,040 --> 00:04:00,260 So if this is the first card then it will stay same light. 47 00:04:00,440 --> 00:04:02,870 So let me show you this one with matchmaker. 48 00:04:03,580 --> 00:04:07,900 So if this is the first card then it will remain in this position. 49 00:04:07,930 --> 00:04:10,160 So this is something I need to take care of. 50 00:04:10,270 --> 00:04:18,350 And if it is second car then only in that condition it will check that whether that's equal or not so 51 00:04:18,560 --> 00:04:19,520 two conditions here. 52 00:04:20,180 --> 00:04:26,060 If this one is first so what will happen in that case. 53 00:04:26,120 --> 00:04:34,250 So if there is no card already done then this my first card is going to be a previous card for the next. 54 00:04:34,250 --> 00:04:35,060 So what will I do. 55 00:04:35,060 --> 00:04:38,960 I will write her previous x equal to x 56 00:04:42,130 --> 00:04:45,690 and previous y equal to y. 57 00:04:45,880 --> 00:04:50,620 I think you will get this thing that what I have done here that it is the first card I will make this 58 00:04:50,620 --> 00:04:59,590 one as the previous because I require this one in the same condition and after that one make first equal 59 00:04:59,590 --> 00:05:01,200 to False. 60 00:05:01,230 --> 00:05:05,410 Otherwise the program will again take this one as my first card. 61 00:05:06,100 --> 00:05:07,170 And again do the same. 62 00:05:08,410 --> 00:05:09,490 Now first is false. 63 00:05:09,490 --> 00:05:13,150 Now it will automatically go for the next commander. 64 00:05:13,150 --> 00:05:15,140 Later on the program again. 65 00:05:15,160 --> 00:05:22,420 So the second come on I added Elif that whether this is a first card or not. 66 00:05:22,450 --> 00:05:26,870 Now at this position we are at this particular position right now. 67 00:05:26,980 --> 00:05:30,540 We have a first card already done and we are going for a second car. 68 00:05:31,190 --> 00:05:32,880 But one more thing here. 69 00:05:33,040 --> 00:05:36,070 What if the user just click the card that is already flipped over. 70 00:05:36,640 --> 00:05:44,370 So what to do at that particular condition so we need to make sure that the user is not clicking the 71 00:05:44,370 --> 00:05:45,120 previous cart. 72 00:05:45,600 --> 00:05:46,840 So that's why I have included. 73 00:05:46,910 --> 00:05:49,730 I live here and have it right here. 74 00:05:50,010 --> 00:06:04,630 Previous X not equal to X or previous Y Not equal to y. 75 00:06:04,780 --> 00:06:09,400 So in that condition it will begin so after that one. 76 00:06:09,670 --> 00:06:16,550 Now we are in this situation that user is clicking any other card except this one. 77 00:06:16,690 --> 00:06:21,770 So I am clicking these these these or these flights. 78 00:06:21,970 --> 00:06:26,650 Now I am in the position when I need to check whether the card is same or not. 79 00:06:27,740 --> 00:06:28,980 So let's check that one. 80 00:06:29,000 --> 00:06:31,860 So first condition if that is not seen. 81 00:06:31,910 --> 00:06:37,380 So if buttons for particular X and Y. 82 00:06:37,390 --> 00:06:44,080 First I will write the previous index and previous y the previous card I have and it's text 83 00:06:47,300 --> 00:06:54,360 is not equal to the buttons that I have right now. 84 00:06:54,410 --> 00:06:55,270 So buttons right. 85 00:06:55,280 --> 00:06:59,250 No I have x y and there next. 86 00:06:59,330 --> 00:07:04,740 So if this is the condition then what will happen in that case. 87 00:07:04,740 --> 00:07:06,310 Just a very small time. 88 00:07:06,390 --> 00:07:11,340 I am not slave for zero point five seconds set so that user cannot see the card. 89 00:07:11,340 --> 00:07:12,600 That is the next day. 90 00:07:14,280 --> 00:07:15,160 And what will I do. 91 00:07:15,390 --> 00:07:16,560 I would just flip them again. 92 00:07:17,010 --> 00:07:31,260 So buttons of previous entries X and previous y previous fly and their text will became empty string. 93 00:07:31,330 --> 00:07:36,340 Now this is the same thing like the changing the color of Caterpillar as the background. 94 00:07:36,460 --> 00:07:38,290 I have just removed the text. 95 00:07:38,290 --> 00:07:42,070 Now few students are thinking that what if I have removed the text. 96 00:07:42,070 --> 00:07:45,900 How will I again get the symbol done so for that cronies. 97 00:07:45,900 --> 00:07:53,370 That's why I have included these four commands in the function because whenever the function sorry button 98 00:07:53,370 --> 00:08:00,010 is cleared it will again call that one and provide the particular button their particular symbol. 99 00:08:00,040 --> 00:08:06,020 This is the reason I have not included them here because in that case was the card is flipped over the 100 00:08:06,040 --> 00:08:10,340 symbol will be go so I hope you understand that thing no. 101 00:08:10,390 --> 00:08:16,350 Hey I have just taken all them in dictionaries and there I have provided them. 102 00:08:16,570 --> 00:08:20,050 Now after that when we are done with this one one more here. 103 00:08:20,050 --> 00:08:21,730 That is extra. 104 00:08:21,730 --> 00:08:30,600 The current cards so buttons and parsed it exclude my wife and their text. 105 00:08:31,570 --> 00:08:33,970 And this unequal to an empty string. 106 00:08:34,750 --> 00:08:36,260 So there we go with that one. 107 00:08:36,850 --> 00:08:42,120 Now we have the as condition so as is automatically the one in which we have. 108 00:08:42,120 --> 00:08:43,840 These are same. 109 00:08:43,840 --> 00:08:53,110 So what will we do in that condition is we will use this visible come on how we will adjust buttons 110 00:08:54,490 --> 00:08:58,610 of previous x and previous y first previous x previous y. 111 00:08:59,050 --> 00:08:59,560 No. 112 00:08:59,590 --> 00:09:05,850 That one day we had previous white and. 113 00:09:05,890 --> 00:09:06,870 Come on. 114 00:09:07,020 --> 00:09:09,540 So the square brackets and come on. 115 00:09:09,990 --> 00:09:15,330 So this is a new way I am using here to access the text and the man because till now we are just writing 116 00:09:15,330 --> 00:09:18,180 them here inside the buttons when we are declaring. 117 00:09:18,630 --> 00:09:20,640 But Wendy Button is already clear. 118 00:09:20,730 --> 00:09:22,830 You can access them by this thing. 119 00:09:23,360 --> 00:09:30,540 So the command will be disabled so once the command is disabled the button will remain in the same position. 120 00:09:32,190 --> 00:09:39,630 Now buttons for current x and y and their command. 121 00:09:40,030 --> 00:09:44,740 So command and that will also be disabled. 122 00:09:47,040 --> 00:09:48,510 There you go. 123 00:09:48,870 --> 00:09:54,640 And after that one when this is a second card make the first one equal to. 124 00:09:54,930 --> 00:10:00,050 So that again the first card will remain in the position when I click that one. 125 00:10:00,240 --> 00:10:06,110 Otherwise that will again do something like No flipping. 126 00:10:06,110 --> 00:10:11,850 So there we go with that one but there is one more thing required in our program. 127 00:10:11,870 --> 00:10:18,950 Like now when you tried to run this one let me have this one one though. 128 00:10:19,580 --> 00:10:20,860 There we go. 129 00:10:21,270 --> 00:10:28,260 When we done that one day you get the error and the added you will get in this line that is here. 130 00:10:28,270 --> 00:10:34,700 We have 42 but if you look at this one then all the things are saying sorry. 131 00:10:34,720 --> 00:10:35,800 Correct. 132 00:10:35,800 --> 00:10:38,020 So how to edit we are getting it. 133 00:10:38,860 --> 00:10:45,220 So there is a very simple concept and a simple answer for this one but little typical to understand 134 00:10:46,890 --> 00:10:48,740 and what that is like. 135 00:10:48,750 --> 00:10:49,650 Look at this one. 136 00:10:49,650 --> 00:10:53,150 Whenever I got any position say zero and zero. 137 00:10:53,490 --> 00:11:01,320 I got this into a button and it will make command for that particular x and y and it will go to the 138 00:11:01,320 --> 00:11:08,940 function that is calling this one and it thinks will work but when another command came when I am clicking 139 00:11:09,080 --> 00:11:11,230 another particular value there. 140 00:11:11,580 --> 00:11:14,100 And this one is calling the x and y. 141 00:11:14,250 --> 00:11:19,150 In that case the same X and Y will value will be transferred to that one. 142 00:11:19,230 --> 00:11:24,000 That's why we are getting here key at 0 0 because the first come on. 143 00:11:24,000 --> 00:11:24,860 That is 0 0. 144 00:11:24,860 --> 00:11:31,170 We are getting zero value for x and zero for Y is going to be parsed again and again to that particular 145 00:11:31,170 --> 00:11:36,710 function because I am clicking the button by using the loops. 146 00:11:36,780 --> 00:11:43,110 I am just creating the button clicking the button is a different thing. 147 00:11:43,370 --> 00:11:50,480 So when I click or create all the buttons here then they are created once but the button command will 148 00:11:50,480 --> 00:11:52,810 work whenever I click them. 149 00:11:53,000 --> 00:12:00,260 It means that they will always be zero 010 so that something how we can resolve them. 150 00:12:00,340 --> 00:12:07,390 One answer for this one is don't use loops just provide 24 times these four commands and provide particular 151 00:12:07,390 --> 00:12:13,810 value for x and y but that will something will make our program too long and it will take a lot of time. 152 00:12:14,530 --> 00:12:15,440 So how to do that. 153 00:12:16,600 --> 00:12:18,980 The answer for that one is what I will do here. 154 00:12:19,120 --> 00:12:25,790 I will add another function to come on I will use to function here one inside of the another what the 155 00:12:25,950 --> 00:12:27,350 first function will do. 156 00:12:27,490 --> 00:12:34,120 It will store all the particular values for x and y that I am getting at that particular instant like 157 00:12:34,120 --> 00:12:36,010 if it is this one is 5 5. 158 00:12:36,010 --> 00:12:43,120 Then it will first store the values 5 and 5 and then it will call the second function with that particular 159 00:12:43,120 --> 00:12:44,980 values 5 and 5. 160 00:12:45,070 --> 00:12:49,000 So I hope you get that one more time seeing again in a very simple way. 161 00:12:50,590 --> 00:12:56,680 Once the buttons are created the all and having the x and y value zero and zero because creating buttons 162 00:12:57,640 --> 00:13:01,890 is a different thing and pressing button is a different thing. 163 00:13:01,960 --> 00:13:06,510 They are not the same but so be sure about that one. 164 00:13:06,820 --> 00:13:09,210 Now how can I add a different function here. 165 00:13:09,400 --> 00:13:15,010 So they already met various methods to our particular functions here and call the function inside that 166 00:13:15,010 --> 00:13:15,560 one. 167 00:13:15,730 --> 00:13:21,430 What I'm using here is a very simple concept that is known as Lambda Lambda functions. 168 00:13:21,430 --> 00:13:26,230 This is a very basic concept and we have not got this one in the course it goes. 169 00:13:26,320 --> 00:13:30,850 This one is very little and did not require much time to understand. 170 00:13:30,850 --> 00:13:38,530 So this is something I can just write lambda and is used only when I need to declare functions in only 171 00:13:38,530 --> 00:13:47,130 one line like lambda provided x and y and write the function z is equal to x plus y so there is something 172 00:13:47,580 --> 00:13:49,710 here we have defined very long functions. 173 00:13:49,710 --> 00:13:52,500 You cannot define very long functions by using lambda. 174 00:13:52,860 --> 00:13:56,330 So you can just define functions in line. 175 00:13:56,430 --> 00:13:57,960 Let me show Dedmon here. 176 00:13:57,960 --> 00:14:02,500 I'm going to define a lambda function and what that will do. 177 00:14:02,620 --> 00:14:06,950 It will first take the value of particular X and store this one in x. 178 00:14:06,970 --> 00:14:15,210 So I'm using the same variable x in x and another valuable y that restored the particular value of y. 179 00:14:15,220 --> 00:14:23,150 So now I have x and y values stored in particular X and Y then the dot nodes mean what will happen then. 180 00:14:23,160 --> 00:14:28,630 So in that one it will just call this function shows symbol. 181 00:14:28,650 --> 00:14:30,950 So I have just righted here something like. 182 00:14:30,950 --> 00:14:35,540 Define that particular function that will take the values and call this one. 183 00:14:35,550 --> 00:14:37,630 But there's something we can do here. 184 00:14:37,710 --> 00:14:39,090 We have to define that function there. 185 00:14:39,960 --> 00:14:47,600 So to define that function in line we use this thing lambda and then X equal to X Y equals Y. 186 00:14:47,600 --> 00:14:53,920 Just this very simple thing and I hope you get this thing that what I have done him and then show symbol 187 00:14:54,080 --> 00:14:56,130 I have called that function. 188 00:14:56,140 --> 00:14:58,170 Now we are ready with a program. 189 00:14:58,210 --> 00:15:03,160 We will get the big cards with very small symbols that we have created him. 190 00:15:03,220 --> 00:15:06,700 Also the symbols here we have created are small. 191 00:15:06,700 --> 00:15:13,840 We have changed the size of card but we will not get these large symbols of the symbol size same. 192 00:15:13,840 --> 00:15:17,060 So now when I run this one I will get by output. 193 00:15:17,650 --> 00:15:19,630 So nothing we have just changed. 194 00:15:19,960 --> 00:15:25,090 We have just added this line and confuse to read it. 195 00:15:25,090 --> 00:15:27,010 This will make no sense like what I am doing here. 196 00:15:27,010 --> 00:15:29,170 I'm just doing X equal to x like worldwide. 197 00:15:29,860 --> 00:15:31,030 But that's very important. 198 00:15:31,030 --> 00:15:33,830 Without that one your program will look what. 199 00:15:34,080 --> 00:15:35,930 Now let's check the walking. 200 00:15:36,280 --> 00:15:37,170 I go to the first car. 201 00:15:37,540 --> 00:15:46,230 And it reminds him I click the second one they disappear this one and let me find a match. 202 00:15:46,220 --> 00:15:47,020 There they go. 203 00:15:47,080 --> 00:15:50,250 When we go to the match we had the same. 204 00:15:50,420 --> 00:15:59,830 They are not changing their position so everything is I believe working fine there we go. 205 00:15:59,830 --> 00:16:08,520 Cesar I think we have this one so we are done with another project here. 206 00:16:09,330 --> 00:16:15,450 And I hope you understand this wondered how the things are working here how the lambda is working here 207 00:16:16,770 --> 00:16:23,560 and this is about discipline you can make them all match lifting to this one. 208 00:16:23,640 --> 00:16:30,900 So this is all about discipline and it's a very little project but contains a lot of topics and lot 209 00:16:30,900 --> 00:16:33,420 of things that makes your things clear. 210 00:16:33,420 --> 00:16:34,290 So thanks for watching. 211 00:16:35,070 --> 00:16:36,150 I would see in the next module.