1 00:00:02,370 --> 00:00:07,530 OK, ladies and gentlemen, today, what we are going to do is we're going to discuss how these ideas, 2 00:00:07,920 --> 00:00:10,410 we can make it dynamic, right? 3 00:00:10,470 --> 00:00:14,400 So you don't have to write anything because I'm going to comment this part and I'm going to do something 4 00:00:14,400 --> 00:00:14,820 here. 5 00:00:15,120 --> 00:00:17,340 And this is just to show you how this is worked. 6 00:00:17,340 --> 00:00:18,410 So bear with me. 7 00:00:18,420 --> 00:00:23,910 I'm just going to explain why I'm going to do I'm just going to create a couple of instances of add 8 00:00:23,910 --> 00:00:29,190 calories of this function constructor and we're going to push it back to the storage. 9 00:00:30,060 --> 00:00:38,880 And after that, what we will expected here is I will explain how we can grab the how we can grab the 10 00:00:38,970 --> 00:00:43,350 last study that we have inserted and what we will do next. 11 00:00:43,530 --> 00:00:43,970 All right. 12 00:00:44,250 --> 00:00:46,860 So manually, I'm going to you don't have to do this. 13 00:00:47,250 --> 00:00:48,930 So I'm going to use this new gallery here. 14 00:00:49,020 --> 00:00:55,530 I'm just going to copy it and I'm going to create new at Cal instance and I'm going to say, OK, zero 15 00:00:55,920 --> 00:00:57,570 one, not one. 16 00:00:57,660 --> 00:00:58,740 It's going to be through one. 17 00:00:59,820 --> 00:01:00,270 What else? 18 00:01:00,530 --> 00:01:02,620 135 in one. 19 00:01:02,820 --> 00:01:05,190 So that will be the description. 20 00:01:05,190 --> 00:01:08,150 That will be calories in the last one will be the quantity. 21 00:01:08,400 --> 00:01:10,740 So I'm just going to paste it here a couple of more times. 22 00:01:10,750 --> 00:01:19,680 I'm going to see one, two, three and four indeed will be one, two, three, four. 23 00:01:20,160 --> 00:01:25,410 Now, this will be four, three, two, one. 24 00:01:25,740 --> 00:01:27,130 And it should be zero, right? 25 00:01:28,260 --> 00:01:31,500 I'm not going to change anything else because that is just the calories. 26 00:01:32,130 --> 00:01:36,930 So now what we need to do is we need to push it to the storage storage. 27 00:01:37,320 --> 00:01:38,790 So we're going to use the same here. 28 00:01:38,790 --> 00:01:39,720 Same, same, same. 29 00:01:41,360 --> 00:01:45,330 And instead of the type I was just going to add, I'm just going to use for this up. 30 00:01:45,330 --> 00:01:48,510 Sorry for this for this area here. 31 00:01:48,510 --> 00:01:52,050 I'm going to add four, five actually values here. 32 00:01:52,050 --> 00:01:57,930 I'm going to push it the net new calorie, but I need to push it manually a couple more times. 33 00:01:58,650 --> 00:02:02,980 So it will be one, two, three and four. 34 00:02:03,330 --> 00:02:12,990 Now, I'm just going to control what I'm just going to control the D storage. 35 00:02:14,250 --> 00:02:19,860 And this one here, I'm just going to comment because I'm controlling like twice. 36 00:02:21,240 --> 00:02:22,830 Let's see what's happening now. 37 00:02:22,830 --> 00:02:25,200 I have to enter something just to go there. 38 00:02:25,410 --> 00:02:28,110 This is not going to be valid right now. 39 00:02:28,110 --> 00:02:29,700 I do have here all calories. 40 00:02:29,910 --> 00:02:36,390 I do have five items inside was going from zero to four. 41 00:02:36,420 --> 00:02:40,230 So the idea should be. 42 00:02:40,440 --> 00:02:41,610 So idea is this. 43 00:02:41,850 --> 00:02:47,490 The idea should be last insert inserted idea plus one. 44 00:02:47,710 --> 00:02:48,090 Right. 45 00:02:48,630 --> 00:02:51,270 And how we can get this last insert ID. 46 00:02:51,780 --> 00:02:59,490 So that is something that we need to consider because if I put it like this, if you go, this is not 47 00:02:59,490 --> 00:03:00,150 some loop. 48 00:03:00,540 --> 00:03:07,440 So you can go from zero to find this one, because if we just remove this one, the last idea will remain 49 00:03:07,440 --> 00:03:08,270 same for. 50 00:03:08,280 --> 00:03:10,530 So that's going to not going to change, right? 51 00:03:10,530 --> 00:03:13,380 I'm just going to save it and I'm going to go back there. 52 00:03:16,490 --> 00:03:19,160 So I do have for now, right? 53 00:03:20,900 --> 00:03:23,360 But the last inserted idea is three. 54 00:03:23,570 --> 00:03:27,050 So if I delete this one, it will be three for a start. 55 00:03:27,090 --> 00:03:32,750 The last thing I did was for if I delete the first one again, the last answer that you will be for. 56 00:03:33,140 --> 00:03:39,640 So I just want to find a way how we can get that last inserted idea and we can do that with the length. 57 00:03:40,520 --> 00:03:41,420 So I'm going to show you. 58 00:03:41,450 --> 00:03:43,980 So I'm going to create here another variable. 59 00:03:44,000 --> 00:03:45,830 So cholerae length. 60 00:03:48,420 --> 00:03:54,120 And I'm going to use this one here, I'm going to say war, not war, sorry. 61 00:03:55,410 --> 00:04:01,380 Well, I'm thinking Kaleri and it will be equal to the storage, not all calories. 62 00:04:02,700 --> 00:04:09,380 And based on this, for example, based on the type, I will get the length here. 63 00:04:09,390 --> 00:04:09,990 I'm going to do it. 64 00:04:09,990 --> 00:04:12,960 This right here. 65 00:04:14,880 --> 00:04:16,020 Right here. 66 00:04:16,020 --> 00:04:21,030 And I'm just going to Konza like these calorie. 67 00:04:23,980 --> 00:04:25,980 Lori length, right? 68 00:04:26,230 --> 00:04:29,350 So you should give me what's happening. 69 00:04:30,310 --> 00:04:30,910 OK. 70 00:04:31,390 --> 00:04:32,180 Something was stuck. 71 00:04:32,200 --> 00:04:39,060 Sorry, ladies and gentlemen, I do have this for right because one we commented out. 72 00:04:39,070 --> 00:04:43,660 So if I just take that one, I don't want to go through the same process again. 73 00:04:43,680 --> 00:04:44,830 And I want to show you something else. 74 00:04:44,830 --> 00:04:45,060 Right. 75 00:04:45,190 --> 00:04:46,850 So it's four elements here. 76 00:04:46,870 --> 00:04:49,270 One, two, three, four. 77 00:04:49,540 --> 00:04:54,910 Now, what I want to do is actually to grab that I.D.. 78 00:04:55,510 --> 00:04:58,080 Well, how we can do this now. 79 00:04:58,090 --> 00:05:03,700 I'm going to save the calorie array, so I'm going to create another variable here. 80 00:05:03,920 --> 00:05:06,540 This is easier, easier for understanding. 81 00:05:06,550 --> 00:05:13,560 So calorie and these calorie is actually will be like this. 82 00:05:14,200 --> 00:05:18,520 So it will be storage that all calories. 83 00:05:20,380 --> 00:05:22,570 And I'm going to say here type. 84 00:05:23,840 --> 00:05:24,100 Right. 85 00:05:25,840 --> 00:05:31,660 Now, the time is already being commented, and I'm going to see and we're going to change that later, 86 00:05:32,830 --> 00:05:34,220 so I'm going to put it like this. 87 00:05:34,240 --> 00:05:37,950 So in this case, I'll arrange this variable here. 88 00:05:37,960 --> 00:05:42,790 I do have the I do have add or burn area. 89 00:05:42,790 --> 00:05:47,680 So I'm going to store them and I'm going to use this one while I'm using this. 90 00:05:47,680 --> 00:05:54,730 You will see at the moment now I'm going to see if it will be equal to these Kalari. 91 00:05:56,470 --> 00:05:56,870 Right. 92 00:05:57,610 --> 00:06:08,500 So I deal with this Kaleri and I already know the length cowl Kalari length that will be minus one inch. 93 00:06:08,500 --> 00:06:11,910 I will grab the idea, simple as that. 94 00:06:11,950 --> 00:06:13,540 So I'm going to cause a log. 95 00:06:17,420 --> 00:06:20,540 Now you will see what will happen, right? 96 00:06:21,050 --> 00:06:24,440 This is not magical, but we are not using the loops with loops. 97 00:06:24,760 --> 00:06:29,480 It's everything is easy here is I grab the idea right now. 98 00:06:29,480 --> 00:06:35,270 If we change this idea to seven, I'm going to grab the seven. 99 00:06:35,270 --> 00:06:35,650 Right. 100 00:06:36,020 --> 00:06:40,490 Although the average length is what is four? 101 00:06:43,970 --> 00:06:51,020 Here is the drilling is for, but the I.D., the actual day that we let sorry we last inserted and that 102 00:06:51,020 --> 00:06:51,580 is seven. 103 00:06:52,070 --> 00:06:53,370 So now it's easy. 104 00:06:53,420 --> 00:06:59,510 Now I know I've I've grabbed this idea in. 105 00:06:59,510 --> 00:07:02,990 All I need to do is I need to incriminate about one. 106 00:07:03,500 --> 00:07:03,930 Right. 107 00:07:04,400 --> 00:07:09,540 So that is how I can get the next I.D. that I want. 108 00:07:09,800 --> 00:07:12,440 So we have to with two possible scenarios. 109 00:07:12,830 --> 00:07:14,920 What if this length is zero? 110 00:07:15,350 --> 00:07:15,600 Right. 111 00:07:15,800 --> 00:07:23,360 So if this length is zero, then what we need to do is actually to say, OK, if it's zero, then the 112 00:07:23,360 --> 00:07:24,330 idea will be zero. 113 00:07:24,350 --> 00:07:25,530 We're going to start from that idea. 114 00:07:26,150 --> 00:07:30,950 So this will just for showing and I hope you understand it right. 115 00:07:31,450 --> 00:07:35,850 I'm just going to I'm going to kill it from here. 116 00:07:36,000 --> 00:07:42,350 Now, if you want to do it, just go back to the lecture, save it somewhere, because I'm not going 117 00:07:42,350 --> 00:07:42,880 to give it to you. 118 00:07:43,040 --> 00:07:44,580 It's not something that you want. 119 00:07:45,060 --> 00:07:45,610 Yeah. 120 00:07:45,630 --> 00:07:49,220 Let's I'm going to say cons of luck storage. 121 00:07:49,220 --> 00:07:52,550 I don't need that one comes a lot and I don't need that one. 122 00:07:52,820 --> 00:07:59,360 So I'm just going to copy to cut this uncommon this in here. 123 00:07:59,360 --> 00:08:01,820 I'm just going to piece them right now. 124 00:08:01,820 --> 00:08:04,610 I do have the calorie length in here. 125 00:08:04,610 --> 00:08:06,350 I'm just going to change by type. 126 00:08:08,130 --> 00:08:15,480 So I hope now you're getting what I'm trying to do and the idea I'm not going to do it like this, so 127 00:08:15,480 --> 00:08:17,660 I have the idea variable here. 128 00:08:18,060 --> 00:08:22,770 So grab this idea, but we need to wrap it up inside if condition. 129 00:08:22,770 --> 00:08:23,060 Right. 130 00:08:23,550 --> 00:08:26,410 So why need the length, for example? 131 00:08:26,430 --> 00:08:38,010 So what we can do here, if calorie length is greater than zero, then I can do this, I can grab the 132 00:08:38,010 --> 00:08:40,770 next item or else I eat. 133 00:08:40,800 --> 00:08:42,150 I will initiate it. 134 00:08:42,390 --> 00:08:47,440 I will I will get the value of this idea to be zero. 135 00:08:47,760 --> 00:08:52,100 So that is pretty much all we need to do now. 136 00:08:52,110 --> 00:08:54,880 Everything else will remain same. 137 00:08:55,770 --> 00:08:57,360 So I do have the idea now. 138 00:08:58,560 --> 00:09:04,160 So remember, we get the calorie length that storage all calories based on the type in the length. 139 00:09:04,560 --> 00:09:11,190 And now I do have this calorie array I'm just getting by the time either will be burned or this one 140 00:09:11,700 --> 00:09:13,410 in here. 141 00:09:13,410 --> 00:09:18,390 I'm just saying calorie array minus one minus minus one of the length. 142 00:09:19,530 --> 00:09:22,890 And I'm grabbing the idea and then I'm adding plus one. 143 00:09:23,970 --> 00:09:31,350 If the calorie length is not greater than zero, that means that we are entering the first element for 144 00:09:31,350 --> 00:09:36,020 this or this array in that will be zero right now. 145 00:09:36,570 --> 00:09:37,220 Let's see. 146 00:09:38,100 --> 00:09:46,190 So all I need to do is actually uncommon, this fella here, and let's hope it's going to work. 147 00:09:46,290 --> 00:09:47,970 So I'm going to say food. 148 00:09:48,870 --> 00:09:50,580 One hundred and fifty. 149 00:09:51,270 --> 00:10:01,400 And I think it is I do have I expect the here to be zero because this condition is not met. 150 00:10:01,500 --> 00:10:01,860 Right. 151 00:10:02,720 --> 00:10:10,320 OK, now is going to come the interesting part, food, another other food example. 152 00:10:10,650 --> 00:10:11,760 And it will be one. 153 00:10:11,760 --> 00:10:13,880 It will be five five five. 154 00:10:14,070 --> 00:10:15,060 We're going to hit enter. 155 00:10:15,300 --> 00:10:19,380 And now I expect to have two items, but with different ideas. 156 00:10:19,950 --> 00:10:24,660 Here is the idea is one, if we add ice cream, how cool is this? 157 00:10:24,660 --> 00:10:34,620 Ladies and gentlemen, here, I will do have another one and it will go to that idea here. 158 00:10:34,620 --> 00:10:36,300 Right now, one more thing. 159 00:10:36,540 --> 00:10:38,280 Let's test it out for exercise. 160 00:10:39,060 --> 00:10:40,350 Exercise one. 161 00:10:43,170 --> 00:10:46,560 OK, I hit twice, maybe my mistake, so I'm going to see what's happening. 162 00:10:47,340 --> 00:10:48,190 Yeah, here it is. 163 00:10:49,200 --> 00:10:54,930 So I expect to have 011 with the same OK exercise, too. 164 00:10:55,300 --> 00:10:58,360 And that will be 37 thirty. 165 00:10:58,490 --> 00:10:59,220 Yeah, like that. 166 00:10:59,230 --> 00:11:00,650 Something doesn't matter. 167 00:11:01,500 --> 00:11:05,610 Now I just want to have three and here it is. 168 00:11:05,940 --> 00:11:06,780 They're working. 169 00:11:06,780 --> 00:11:09,450 So even the burn calories now everything is working. 170 00:11:10,620 --> 00:11:12,660 So how cool is this. 171 00:11:12,960 --> 00:11:17,240 Our application, ladies and gentlemen, start to look something like it. 172 00:11:17,250 --> 00:11:21,910 You know, I'm just going to save it here like this. 173 00:11:22,020 --> 00:11:23,970 So we grab the idea once more. 174 00:11:23,970 --> 00:11:29,040 If the length is zero, then if it's greater than zero, we going to grab the last idea. 175 00:11:29,040 --> 00:11:32,380 We're going to incremented one and else. 176 00:11:32,610 --> 00:11:36,270 If it's the first in the area, we're going to grab zero. 177 00:11:36,450 --> 00:11:37,800 And that's pretty much it here. 178 00:11:37,950 --> 00:11:41,510 We explained last time what we are doing and that's pretty much it. 179 00:11:41,700 --> 00:11:48,930 So we need to find a way how after what we have done here, we need to display somewhere. 180 00:11:48,930 --> 00:11:49,200 Right. 181 00:11:49,200 --> 00:11:52,680 We don't have it anywhere in this place right now. 182 00:11:53,160 --> 00:12:03,270 That will be our goal to display these results, these items or calories as you want from on the on 183 00:12:03,270 --> 00:12:05,850 the front or you are on the on the front. 184 00:12:05,850 --> 00:12:06,140 You are. 185 00:12:06,300 --> 00:12:07,310 So that's pretty much it. 186 00:12:07,500 --> 00:12:08,340 Thank you for watching. 187 00:12:08,350 --> 00:12:15,510 And I hope you understand if you don't please me, watch the video and I will see you in the next one.