In this coning lecture, I'm going to solve the parts of a day challenge, let's get started.
All right, now let's get back to the court.
Now I'm going to short declare a variable age like this, this will store the current our.
Now, I'm going to call the now function from the time package.
Then in turn from it, I'm going to call our method.
As I showed you before time, that now here returns a time value for the current site.
And it has aberrated.
As you can see, it returns to Iowa as an int.
So now this age variable here is also an incredible.
OK, let's print this variable to the console like this.
Now, let's run it.
As you can see it, Prince, the current our.
All right, let's get back and print the part of today, using this our way will.
First, I'll check whether the current hour is around evening like this.
If so, then I'll print good evening.
Now, let's check for the afternoon part of the day like this.
So it's not the evening time, nor we'll check this second case condition.
So if the hour is greater than or equal to 12, then it should be afternoon.
As you can see, the order of the case clauses are very important to this program.
On each case, I'm trying to narrow the range of Iris.
Now, let's check for the morning part of the day like this.
And lastly, if the hour is less than six, then it should be night dango as a last resort will execute
this default class.
Now, the program is really.
Now, let's move this short declaration into the swift statement like this, I'm going to cut it from
here and move it to here.
Here, I've just moved the short declaration that I put the surprise there are next to it with an empty
condition, remember, an empty condition means true.
First, let me set my clock to a morning hour from here.
Apply.
OK, now let's run the program.
Cool.
Good morning to you, too.
But it's not morning here, I'm just faked it anyway.
Now, I'm going to set my time to afternoon.
OK, that's right now.
Good note says good afternoon.
Now, let's set my time to evening.
Now it says good evening.
And lastly, that set my time tonight, our.
Good.
It works perfectly.
By the way, since I've declared the Arabel travel inside switch statement, it won't be available here.
So, for example, I can't print it like this.
As you can see, Gore says that it doesn't exist here.
You can learn more information about this in their statements, scoping and the shadowing lectures,
by the way.
All right, that's all for now, see in the next picture, bye bye.