Hello, in this video we are going to cover constructors. So a constructor is a function that is run as soon as you create a object for the class. So we created objects here. So this is one and it could be used for initial setup of class, the format of a constructor, public function. And what you do is you call it underscore, underscore, Doctor, like so. And now, I'm just gonna say for echo here, that's just gonna say, I began.
I pour a gallon apparently. And I will also put this in a div and I'll just do a bit of inline styling. Go equals So far and that is an open interest in give me narrow political muscle. Yep, there we go. I made a mistake. It's an unscored score construct not construct called a construct.
But I put any armor at the end my bad. So if I actually removed all this code, and literally or if I remove this as well, let me show you up and we get nothing. If I put that back in, so we haven't used any of the properties, yet, we've only actually created the classes. We have a phase I have begun. So initially, this function Always caught if you don't explicitly create your own constructor, the compiler will create a background constructor that is a requirement, but it will there always will be one it's good to have one there and to set up initial value and you know instead of you know this, we could put something like this. Copy this.
He could set these up. No arrows fantastic. And if you just print them out for the dollar OBJ print info. It prints out all the info. So it's a great way of setting up variables in a site, we can make it a bit more dynamic, because at the end of the day, this is a function. And like any other function, if you know what the functions policy, we highly recommend do that.
But like any other function of said function like a million times, I will say one more time, like any other function, you can pass values in my thinking, how do you do that, let me leave you with this. You can also create object objects for flight this that should make it a bit more obvious now. So here we have a call and what this is, you know, same thing as not having it there. But this is showing you that it is calling the constructor. So, what I want you to do is extend the constructor. So, he takes in three variables, one the speed of acceleration and one for wheels.
And then you pass in three parameters here for each vehicle. So that way you can set different speed acceleration and we'll You know, properties. And that's it for the constructor. Any questions, feel free to pop me a message. And as usual, I look forward to seeing you in the next video.