Welcome back.
In this and the following lectures, I'm going to show you how to build the command line Digital Clock
with Step-By-Step explanations.
All right, let's get started.
OK, let's take a look at the goals first.
All right.
For the first step, we have four goals.
Let's start with the first one.
The first goal is about declaring a new placeholder type, as you'll see in a minute.
This will make things easier to read.
First, I'm going to type type, then I'm going to call it placeholder.
I want this type to be an area with five string elements like this.
All right, let me open the goals again and let mark this goal as finished, like so yeah, that was
easy, but this was the first goal.
OK, now let's take a look at the second goal.
Our second goal is about creating the digits.
Cool.
Let's do that now.
But before that, let's remember what a digit looks like again for each line here, I'm going to add
an element to this placeholder array.
I'm going to do this because I want to print it line by line.
OK.
All right.
Let's get back to the card.
So first, I'm going to create a new variable for the zero digit like this.
Then I'm going to assign it an error by using the placeholder type, so this will be an error with five
string elements, it's all because the placeholder type represents an array with five string elements.
OK.
It's like typing it like this.
OK, it just like an error, literally.
Now I'm going to add the elements line by line.
I want to draw of zero.
So I'm going to add three boxes in a string literal like this.
Then let me draw its columns like so, and lastly, I'm going to add three more boxes here for the Futer,
OK?
Now it looks like zero, right?
However, not that actually this is just an array with five string elements.
Now I'm going to add another variable to represent one.
Let me fast forward this.
As you can see, it's just another variable, let me add the other digits as they are similar.
So let me fast forward it.
All right.
As you can see, there are 10 variables for each digit from zero to nine.
Nothing magical here right now.
OK, I also completed the second girl, now let me mark it off, OK?
Now let's take a look at the Turko.
So I need to put the digits into an area to get down from that area easily afterwards.
OK, let me save this file first.
As usual warns me, because I didn't use these variables yet.
Right.
So let me put them into another array called digits.
Now I'm going to assign it a placeholder error.
Now I'm going to add all the digits into this array.
I'm adding all the digit arrays as placeholders, OK?
All right.
So this digits error is a multidimensional error, which stores 10 placeholder arrays, sort of.
These are actually looks like something like this.
It has 10 elements for each placeholder array and each placeholder array has five string elements.
All right, let's get back.
Let me check out the girls again.
I also completed the third goal, labor market of.
Good.
Now, the next goal is printing the digits side by side do that.
Let's print the first digit by using the digits area first.
I'm going to call Princella and then I'm going to get the first element.
All right.
Limerence.
As you can see, this is not the result that I want is because it has printed all the lines in the same
line, but I need to print them line by line.
OK, so how can I print them like so?
I can use a loop, right, let's do that right now.
I only need the elements, so I'm going to skip the index variable, then I'm going to get the element
variable only LACHSA, and now I'm going to range over the first digit.
And lastly, let me print it like this.
All right, that's right.
Good.
This time it has printed the zero perfectly, right, but I also want to print all the digits.
So instead of ranging over a single digit range over all the digits like this.
Now, I'm also going to change the name of this variable to digits.
It's more readable this way.
But I'm not finished yet.
Now, this loop returns to digital only.
I also need to print them line by line.
So I'm going to add a nested loop here.
Now, I'm going to loop for each line in this digital era.
All right.
Let me also add print on here to give it a space before printing the next digit.
All right, let's write.
Cool, it works.
Now, the next thing I need to do is to print them side by side.
Let me show you how can I do it?
I need to print each line one by one, as I said, for example, here I have printed the first line
of all the digits together in a single line.
Then I'm going to print the next line for all the digits again.
I'll continue to do so until I print all the digits.
To do this, I need to loop five times, it's because there are five lines in a single digit, right?
Let me delete this loop here first, because it loops over all digits, then it prints all the lines
for each digit.
However, as I show you, I need to print all the digits line by line.
There are five lines in a digit.
Right.
So I'm going to loop for five times like this.
Here I have used the first digit array, but I could have used second digit array as well or the other
ones.
It doesn't matter.
The only important thing here is that I'm looping four, five times.
For example, I could type it like this.
They are the same.
All right.
Now I need to print the next line of all the digits together.
To do that.
I'm going to type a nested loop here.
I only need to get the index variable.
You'll see why in a second.
Then I'm going to range over all the digits.
All right, almost done.
Now I need to print a line from each digit.
Now I'm going to get the next digits from the digits like this, these are turns a digital array, but
I need to get a single line from it, right.
So now I'm going to get the current line from it like so.
All right, let's try it.
Oops, I made a mistake.
I also need to add a new line here.
OK, this will add a new line after printing a new line.
All right, let's try it again.
Cool.
It's getting better.
As you can see, there isn't enough space between them.
So let me add two space characters here to separate them.
OK, let's write.
Nice.
OK, let me check the girls again.
Cool, I have completed the last goal as a.
All right, that's all for now.
Let's take a quick break here.
In the next lecture, I'm going to show you how to draw the digital clock.
See you there.
Bye bye.