00:01
Okay, good day, ladies and gentlemen.
00:06
We are looking alive at problem number 710.
00:12
And it is a bit of a doozy, i'm afraid.
00:17
It really is a bit of a doozy.
00:19
It's a time class problem.
00:23
And so it's, i mean, it sort of, you know, basically, it's based off one of the problems earlier in the class.
00:36
It would have been, like, two points.
00:40
He says it's from listing 2 .7.
00:45
But, okay.
00:47
So what we're supposed to do is we're supposed to create this time class, which has two private data fields or three private data fields.
01:01
It constructs a time which initializes the hour, minutes, and second using the current time, and then corresponding get methods for the private data fields, and then it creates this method set time of elapsed time that creates a new time based off the elapsed time.
01:29
Okay.
01:31
So with all of that being said or sort of said, let's begin with the, so i've actually, okay, i'm just going to admit, i've already pre -done it.
01:44
I've already done it already because this is a bit frustrating, i think, to be honest with you.
01:52
So basically, i've already done it.
01:54
And i just want to sort of talk you through what i've done.
01:54
So the first thing, i'm a bit frustrating.
01:54
So basically, i've already done it.
01:55
And i just want to sort of talk you through what i've done.
01:58
So the first, first thing you want to do is just import time because that's what we're going to be using.
02:04
So we're going to be using the time module to initialize the times.
02:13
And my class is called time.
02:17
Now variables are private, but i'm initializing them from the module.
02:29
So the time.
02:33
Time method will set a certain number of seconds, and then i take the integer value.
02:41
And all of this theory is explained in the book, so i'm not going to try to get too deep into it, because really i just used exactly the calculations he did in 2 .7.
02:56
So, you know, i took the total minutes to be the, you know, you divided by 60 and then take the lower part, the lower and the total hours again to be the total minutes divided by 60.
03:16
And then because i want to set this to the current one, i just mod it by 60 here or you modular wrist.
03:28
Arithmetic and modular arithmetic on the, again, these are private variables here.
03:35
And i decided to sort of introduce these intermediary variables just because i think it's a little cleaner, but, you know, that's up to you.
03:45
These intermediary variables up here, these total seconds, and then i just used them here because i think it's a little cleaner to do it this way, but there's no, i don't think you have to.
03:58
I just do it that way.
04:01
Okay, once i've gotten the variables or the private variable set, then i go down here and these are the assessor methods.
04:14
So just to, you can print them out, you know, the values.
04:21
You can print them out as we will shortly.
04:25
And then here, down here finally, this set time method, which is a bit of a bit annoying, i think, and i'm not even exactly certain.
04:44
Anyhow, so i just calculated the corresponding values.
04:50
And then i did the test.
04:54
So the test, oops, wrong one here.
04:58
Oops, again, can't do the right thing here.
05:02
And then the test module, so in the test, now i'm just importing time.
05:09
So i'm from time class, that's what i called that file.
05:15
I import time...