Welcome back.
In the second step, I'm going to explain how are we going to print the clock by using the current time
and the digits that we have created in the last lecture.
OK, let's get started.
All right, let's take a look at the goals first.
I have these four goals, right?
First, I'm going to get the current time, then I'm going to separate it into over a minute and second
values, then I'm going to create the clocker by getting them from the digits area that I created in
the last lecture.
And then I'm going to print the clock.
It will display the current time.
And lastly, I'm going to add the separators between the hour, minute and seconds.
All right.
Let's start with the first goal, the.
Our first goal is simple, getting the current time, you have to do it already, right?
Let me first declare a variable like so then I'm going to call the time that now function to get the
current time like this.
All right.
Now, variable contains a time type which in turn stores the current time.
Let's use it to get the current hour, minute and second.
OK, now I'm going to declare three variables.
Our.
Mean and sick, OK, now I'm going to get the current hour by using the our method of the time type
like this.
As you know now, variables type is time and the time type has a Arber method.
OK, now I'm going to get the current minute and lastly, I'm going to get this second.
OK, let me print them so you can see what they are storing.
OK, cool.
I'm going to use this soon.
Let's check out the girls again.
OK, I've finished the first go.
Let me check it off from the list.
The next thing is creating the clocker.
Let's do that.
But before that, let's remember the clock erra again to print this clock, I need to start the digits
in a multidimensional array called the clock.
Remember, it has eight placeholders, six of them four digits, and two of them for the separators.
As you can see, each placeholder is an array of five strings.
Just like the digitizers.
And the yellow lines represent the placeholder elements, which are string values.
All right, let's create this aura.
Now I'm going to declare a clock variable, then I'm going to type the length of the error using ellipses,
and lastly, I'm going to type the element type as placeholder.
So after I finish, this will be a multidimensional array with a placeholder elements like this.
I'm going to fill it with the fake digits for now so that I can explain it to you how it's going to
work.
OK, here I'm filling it with digits arrays randomly.
These are just fake data for now, of course.
OK, I created the clock.
The next goal is printing the clock.
Let's do that.
Here in this loop, instead of printing the digits, using the digits there, now, I'm going to get
them from the clocks, right?
This is because the clock array will contain the current time.
I can use the same loop.
OK, so now I'm going to change.
All the digits are easier to clocks, arrays like this.
Now the loop gets the digits from the clocks array instead of the digits array.
OK, I had used the digits array only to print the digits.
Now it will print the actual clock.
That's right.
As you can see, it prints the digits that are put into the clocks are right.
If you look at the indexes that I've used here, you can see that it brings the clock that is equal
to the indexes.
For example, digits one prints one digits, zero prints zero digits, two prints, two digits, three
brains, three and so on.
So just by using the indexes, I can print any digit like this.
OK, now, instead of printing random digits, let's print the current time.
Let's start with the current hour.
Let me first delete the rest of the digits first.
OK, now I'm going to get the first digit of the current hour like this here.
I divided the hour by 10.
So this will return the first digit of the current hour.
OK, then I'm going to get the second digit of the current hour like this.
Let me show you what it looks like.
Cool.
It brings the current hour in nice retro digits.
So when you divide an integer number with 10, it will give you its first digit.
This is because an integer doesn't have a fractional part.
So here it returns one because 12 divided by 10 is one.
And then use the remainder operator like this.
It will give you the remainder after the division by 10.
So here it returns two because the remainder of 12 by 10 is two.
OK, it is time to print the digits for the current minute.
I'm going to duplicate this line that I'm going to change to our variables with the mean variables.
Let's try it.
As you can see for the current minute here at Prince, four to five, it is correct.
OK, let's do the same thing for the current second.
I'm going to duplicate this line.
Then I'm going to change the many variables with the SEC variables.
OK, let's try, as you can see, for the current seconds, it preens 18, which is correct.
Cool.
Our club is ready and it shows the current time.
Let's check out the goals again.
All right.
I print the clock, so let me check this goal off.
Let's take a look at the next goal, OK?
Has the last goal I need to at the separators.
Let's get started.
OK, now I'm going to create another placeholder called the column like this.
This where you will store the separator between the hours, minutes and seconds.
OK, now I'm going to add five string elements to it here.
I'm going to add this box character right here.
Then another one here.
It looks like a separator, right?
Because it is now I'm going to put this separator into the clock right between the hour minute and the
second Lexar and another one here.
OK, let's try.
Cool.
Right now, it really looks like a real clock, isn't it?
All right, let's check out the girls again.
Let me check off the last girl as well.
All right.
Let's take a quick break here in the next lecture.
I'm going to animate the clock.
See you there.
Oh, I.