WEBVTT 00:01.210 --> 00:01.980 Welcome back. 00:02.950 --> 00:08.440 In this and the following lectures, I'm going to show you how to build the command line Digital Clock 00:08.440 --> 00:10.430 with Step-By-Step explanations. 00:10.950 --> 00:12.160 All right, let's get started. 00:12.940 --> 00:15.100 OK, let's take a look at the goals first. 00:15.550 --> 00:15.970 All right. 00:15.970 --> 00:18.100 For the first step, we have four goals. 00:18.550 --> 00:20.170 Let's start with the first one. 00:20.590 --> 00:26.140 The first goal is about declaring a new placeholder type, as you'll see in a minute. 00:26.170 --> 00:28.300 This will make things easier to read. 00:29.280 --> 00:33.750 First, I'm going to type type, then I'm going to call it placeholder. 00:34.680 --> 00:38.550 I want this type to be an area with five string elements like this. 00:39.720 --> 00:45.780 All right, let me open the goals again and let mark this goal as finished, like so yeah, that was 00:45.780 --> 00:47.910 easy, but this was the first goal. 00:48.750 --> 00:51.330 OK, now let's take a look at the second goal. 00:51.900 --> 00:54.900 Our second goal is about creating the digits. 00:55.350 --> 00:55.730 Cool. 00:56.130 --> 00:56.960 Let's do that now. 00:57.450 --> 01:03.450 But before that, let's remember what a digit looks like again for each line here, I'm going to add 01:03.450 --> 01:05.610 an element to this placeholder array. 01:06.330 --> 01:10.200 I'm going to do this because I want to print it line by line. 01:10.350 --> 01:10.670 OK. 01:11.330 --> 01:11.850 All right. 01:11.850 --> 01:13.020 Let's get back to the card. 01:14.070 --> 01:18.300 So first, I'm going to create a new variable for the zero digit like this. 01:19.290 --> 01:25.080 Then I'm going to assign it an error by using the placeholder type, so this will be an error with five 01:25.080 --> 01:31.830 string elements, it's all because the placeholder type represents an array with five string elements. 01:31.960 --> 01:32.340 OK. 01:32.940 --> 01:34.500 It's like typing it like this. 01:35.100 --> 01:37.590 OK, it just like an error, literally. 01:38.400 --> 01:40.650 Now I'm going to add the elements line by line. 01:41.400 --> 01:42.620 I want to draw of zero. 01:42.660 --> 01:46.320 So I'm going to add three boxes in a string literal like this. 01:47.220 --> 01:53.920 Then let me draw its columns like so, and lastly, I'm going to add three more boxes here for the Futer, 01:54.780 --> 01:55.180 OK? 01:55.260 --> 01:57.620 Now it looks like zero, right? 01:58.110 --> 02:02.940 However, not that actually this is just an array with five string elements. 02:03.720 --> 02:06.610 Now I'm going to add another variable to represent one. 02:07.230 --> 02:08.790 Let me fast forward this. 02:10.150 --> 02:17.450 As you can see, it's just another variable, let me add the other digits as they are similar. 02:17.500 --> 02:19.120 So let me fast forward it. 02:19.810 --> 02:20.290 All right. 02:20.330 --> 02:25.330 As you can see, there are 10 variables for each digit from zero to nine. 02:26.430 --> 02:28.170 Nothing magical here right now. 02:29.190 --> 02:34.290 OK, I also completed the second girl, now let me mark it off, OK? 02:34.680 --> 02:36.480 Now let's take a look at the Turko. 02:37.110 --> 02:42.310 So I need to put the digits into an area to get down from that area easily afterwards. 02:42.570 --> 02:45.240 OK, let me save this file first. 02:45.840 --> 02:49.840 As usual warns me, because I didn't use these variables yet. 02:49.860 --> 02:50.280 Right. 02:51.180 --> 02:54.250 So let me put them into another array called digits. 02:55.020 --> 02:57.160 Now I'm going to assign it a placeholder error. 02:58.080 --> 03:00.690 Now I'm going to add all the digits into this array. 03:00.870 --> 03:04.450 I'm adding all the digit arrays as placeholders, OK? 03:05.240 --> 03:05.660 All right. 03:06.300 --> 03:12.680 So this digits error is a multidimensional error, which stores 10 placeholder arrays, sort of. 03:12.700 --> 03:15.900 These are actually looks like something like this. 03:16.200 --> 03:23.100 It has 10 elements for each placeholder array and each placeholder array has five string elements. 03:24.370 --> 03:25.480 All right, let's get back. 03:26.350 --> 03:27.930 Let me check out the girls again. 03:29.230 --> 03:32.380 I also completed the third goal, labor market of. 03:33.590 --> 03:33.900 Good. 03:34.070 --> 03:38.570 Now, the next goal is printing the digits side by side do that. 03:39.470 --> 03:42.930 Let's print the first digit by using the digits area first. 03:43.040 --> 03:47.180 I'm going to call Princella and then I'm going to get the first element. 03:47.810 --> 03:48.320 All right. 03:48.320 --> 03:48.950 Limerence. 03:49.900 --> 03:56.680 As you can see, this is not the result that I want is because it has printed all the lines in the same 03:56.680 --> 04:00.100 line, but I need to print them line by line. 04:00.680 --> 04:03.250 OK, so how can I print them like so? 04:04.250 --> 04:07.800 I can use a loop, right, let's do that right now. 04:07.940 --> 04:13.340 I only need the elements, so I'm going to skip the index variable, then I'm going to get the element 04:13.340 --> 04:18.080 variable only LACHSA, and now I'm going to range over the first digit. 04:20.330 --> 04:22.550 And lastly, let me print it like this. 04:23.800 --> 04:25.180 All right, that's right. 04:26.360 --> 04:26.700 Good. 04:26.870 --> 04:32.530 This time it has printed the zero perfectly, right, but I also want to print all the digits. 04:32.990 --> 04:38.090 So instead of ranging over a single digit range over all the digits like this. 04:38.990 --> 04:42.130 Now, I'm also going to change the name of this variable to digits. 04:42.890 --> 04:44.210 It's more readable this way. 04:45.380 --> 04:46.560 But I'm not finished yet. 04:46.970 --> 04:49.980 Now, this loop returns to digital only. 04:50.510 --> 04:52.720 I also need to print them line by line. 04:53.240 --> 04:54.980 So I'm going to add a nested loop here. 04:55.670 --> 04:58.400 Now, I'm going to loop for each line in this digital era. 04:58.820 --> 04:59.270 All right. 04:59.780 --> 05:04.100 Let me also add print on here to give it a space before printing the next digit. 05:04.910 --> 05:05.990 All right, let's write. 05:07.040 --> 05:08.000 Cool, it works. 05:08.210 --> 05:12.360 Now, the next thing I need to do is to print them side by side. 05:13.010 --> 05:14.470 Let me show you how can I do it? 05:16.480 --> 05:22.060 I need to print each line one by one, as I said, for example, here I have printed the first line 05:22.060 --> 05:24.570 of all the digits together in a single line. 05:25.450 --> 05:28.270 Then I'm going to print the next line for all the digits again. 05:30.110 --> 05:33.470 I'll continue to do so until I print all the digits. 05:34.540 --> 05:41.130 To do this, I need to loop five times, it's because there are five lines in a single digit, right? 05:42.100 --> 05:47.620 Let me delete this loop here first, because it loops over all digits, then it prints all the lines 05:47.620 --> 05:48.460 for each digit. 05:48.710 --> 05:52.810 However, as I show you, I need to print all the digits line by line. 05:53.110 --> 05:54.690 There are five lines in a digit. 05:54.700 --> 05:55.050 Right. 05:55.420 --> 05:57.760 So I'm going to loop for five times like this. 05:59.190 --> 06:05.040 Here I have used the first digit array, but I could have used second digit array as well or the other 06:05.040 --> 06:05.320 ones. 06:05.340 --> 06:06.150 It doesn't matter. 06:06.450 --> 06:10.280 The only important thing here is that I'm looping four, five times. 06:10.590 --> 06:12.930 For example, I could type it like this. 06:13.470 --> 06:14.210 They are the same. 06:15.030 --> 06:15.380 All right. 06:15.510 --> 06:18.510 Now I need to print the next line of all the digits together. 06:18.780 --> 06:19.430 To do that. 06:19.440 --> 06:21.150 I'm going to type a nested loop here. 06:21.420 --> 06:23.760 I only need to get the index variable. 06:23.760 --> 06:25.410 You'll see why in a second. 06:25.620 --> 06:27.690 Then I'm going to range over all the digits. 06:28.640 --> 06:29.820 All right, almost done. 06:30.200 --> 06:32.720 Now I need to print a line from each digit. 06:33.760 --> 06:39.880 Now I'm going to get the next digits from the digits like this, these are turns a digital array, but 06:39.880 --> 06:42.270 I need to get a single line from it, right. 06:42.430 --> 06:45.190 So now I'm going to get the current line from it like so. 06:46.060 --> 06:47.200 All right, let's try it. 06:48.070 --> 06:49.720 Oops, I made a mistake. 06:50.170 --> 06:52.360 I also need to add a new line here. 06:52.630 --> 06:56.020 OK, this will add a new line after printing a new line. 06:56.620 --> 06:57.930 All right, let's try it again. 06:58.450 --> 06:58.830 Cool. 06:58.840 --> 06:59.680 It's getting better. 07:00.380 --> 07:03.210 As you can see, there isn't enough space between them. 07:03.520 --> 07:06.910 So let me add two space characters here to separate them. 07:07.720 --> 07:08.830 OK, let's write. 07:10.300 --> 07:10.870 Nice. 07:13.100 --> 07:14.700 OK, let me check the girls again. 07:15.350 --> 07:17.900 Cool, I have completed the last goal as a. 07:18.320 --> 07:19.900 All right, that's all for now. 07:19.970 --> 07:21.260 Let's take a quick break here. 07:21.260 --> 07:24.770 In the next lecture, I'm going to show you how to draw the digital clock. 07:25.010 --> 07:25.640 See you there. 07:25.730 --> 07:26.120 Bye bye.