I want to add a quick note about this constructor function.
Remember, this gets called every time we instantiate an object and this is how we create custom objects.
Right.
But an interesting thing that you can do here, because you have control over how the instantiation
happens, you can do different safeguards.
For example, let's remove this for now because we don't need it.
Or actually let's change this to let's to h we want to check if the user is over 18 then we're going
to run this otherwise.
Well, the program is going to error out because we only let people age 18 and over to play the game
because let's say it's rated R so we can do different things in the constructor to make sure that we
are instantiating the object the proper way.
We can also give default parameters like name can be anonymous if we wanted to.
If they don't provide a name and then age will be, let's say, zero if they don't provide an age.
So that here let's say I forget to instantiate player one and player two if I click Run.
I get an air player object has no attribute name.
And this is on line 11.
Now, why do we not have self name?
Well, because on line 17 they were trying to call shout.
But unfortunately we never instantiated this because when we don't provide anything, the age is going
to be zero.
So we're never going to instantiate with these properties.
Okay.
So let's just give it Tom.
And then age is going to be ten.
And let's just remove player two for now.
If I do, player one scout and I click Run.
Once again, I get an error because, well, Tom is only ten years old.
We're not going to create this character.
Now we're going to talk about errors.
And maybe instead of just having this error out, we can send a message saying, hey, player is not
old enough.
But for now, I hope you see the power that comes with this idea of constructor and the instantiation
of an object where we're able to add these different controls and safeguards to perhaps make sure that
we receive the right data type in order to create the object.
Or maybe the age is over 18 in order to make sure that when we actually instantiate this player one
object, we're doing it the right way.
So this init gives you a lot of control.