 What's going on, guys? Rudlinal here, coming back at you with another Python tutorial. Welcome to your 30th tutorial. Actually, give yourself a pat on the back for coming so far. And now remember we've been taking a little bit of an adventure in the world of OOP, or Object-Oriented Programming. And Object-Oriented Programming is that sort of paradigm or that mindset where you're using objects or instances in your code. And these instances are sort of like machines. They can do things like functions, they have methods and that sort of thing. They contain qualities, attributes and properties, like variables and that sort of thing. Now the thing is because you're able to make multiple of these things, like so you have instances, like if you want to have like five enemies for a game, you have the option to do something called inheritance. Now inheritance is when you have multiple classes and some of which have derived characteristics from the original. And you can sort of picture this with like parents and children. Children could have all or some of those traits that are inherited. And obviously in the program, of course, you can change some of these if you want to. In those scenarios though, the parent class is considered the super class like it's above, like that Latin root soup. And then while the child class is below, it's considered the subclass or underneath. So let's give it a go. Let's open up Idle and I'll show you what we're going to roll with today. Drag this over here, create a new program, save this as a file.python, overwrite it, user, user, bin, environment, Python. And let's get started. I'm going to create a class first of all just because we want it to. And this is going to be a plain regular class, but this is going to be the mother. So we can set mother to be equal. And we're going to give her a constructor, define, initializing. We need that self keyword as always because it's a function inside there. And I'm actually not going to pass any more arguments other than that. We'll create all the variables inside the code block. So now her first name, we can have it be Alice or something. It doesn't really matter. And then her last name will be Hawkins. So now the mother is what's going to have the children. But obviously, we don't want all the children to have the name Alice. So we want to create a new function where you can set the first name. And then we'll change the parameter in here, name to be set to. So this can be a string variable and we can just set the name to be that. Now that we have that code block going, we can set self. Oh, we should change the last name before I forget that self last name is going to be Hawkins. And now self.firstName can equal what we set the name to be. Name to be set to. There you go. Okay. So now let's create Alice. Alice is the mother. What I'm going to do here quickly is create a full name. And we can change that to self.firstName. And we can concatenate a space under there and then concatenate her last name. I can create a new function to say hello. Just so we have a little bit of output. And we can just display self.fullName says hello. Okay. So now we have Alice, which is the mother. If we print this, if we run this, we don't get any output though. But if we do Alice.sayHello, we can get some output there. And it's going to display Alice Hawkins says hello. Alice Hawkins says hello because we've set up Alice is the first name. Hawkins is the last name. The full name is both of these together. And then when we say hello, we just display that along with saying hello. So let's get ourselves a class that is going to be our child. Our child class, I'm just going to call it child. And the syntax for inheritance is just two parentheses after the class name. And then the class that you're inheriting from inside those parentheses. So let's finish up that code block. And now everything that the mother has set is going to be set up as the child. So we can set his first, we're going to be able to use this set first name to be this one here. But the child has an as an interesting function. We're going to change him to have a get married function self and then a whole other child object. Actually, we'll change it to a soulmate object. Now, let's change the soulmate. Actually self dot last name can be soulmates dot last name. So now what we can do Bob equals a child. And he's not going to have any parameters because there aren't any in mother. Except for the moment Bob's name is Alice. And that's just a little weird. Let's change it to, first of all, let's have him say hello so we get introduced to Bob. Alice Hawkins says hello. That doesn't make any sense though. It's Bob. So we want to change Bob's name. So we can use our function that we defined set first name and have him become Bob. It's Bob Hawkins. Oh, we run this. Set first name to be named to be set to. Is that working for us? No. Oh, I see, I see. Because we aren't changing the full name inside set first name. This is a good example. This is something that we should be considering. Because we're using that full name in the say hello function, we have to be able to differentiate between the full name and the first name. If we change that first name, we're also going to want to change the full name along with it. Let's make this a little bit bigger here so you guys can see what we're doing. And let's run the program again. Alice Hawkins says hello. And then Bob Hawkins, her son, in this scenario, says hello. Except in the child class, we aren't defining the constructor. We aren't defining the say hello or the set first name. All of these are already inherited by the child. In this case, Bob. So now let's create a new one. Let's set soulmate. And now this can be self, first of all. Actually, no, we don't want to have it inherit anything. I was getting ahead of myself and thinking about the constructor. Inside the constructor, we're going to want, obviously to have the self keyword, we're going to want the name. And that's all. Actually, we want first name and last name. So now we'll close that code block and self.firstName equals firstName. And then self.lastName can be equal to lastName. So now let's say... Okay, so we've got our new person here. We've got a soulmate going along. So let's set alley. Alley can be our soulmate. And alley can be alley. And her last name can be how about dearing. Alley dearing. And let's have her be able to say hello as well. So we're just going to copy this function and put it in here because we don't want her to be able to inherit anything because she's a completely different sort of person. So Bob says hi. And now Alley's going to say hello as well. So we run this. Soulmate has no attribute full name. Oh, good. We're going to want to be able to change this as well. So when we have that first name and the last name, we're going to build a full name along with it. Alley dearing says hello. Okay, cool. So now we can do a whole new thing with Bob because Bob has this option to be able to get married. That's inside of his class. It's inside of his framework or his blueprint. So we can get married to a soulmate, which in our case can be an object. So we're going to pass in alley to the get married function. Bob is going to get married to alley. Now when we run this, nothing else is going to happen but Bob's last name has suddenly become, let's see, Alley's last name. So in our case, Bob is now dearing. Actually, Alley should be the one getting married so we should probably be changing around our names here. But hey, we can do that when we're done. So Bob is going to say hello. If we run this, Bob Hawkins says hello. But let's see here. Self.lastname is equal to last name and we want to change the full name along with that. So that's an easy thing to forget. Because we're using two variables and we're always resetting them, we should be able to keep that in mind whenever we're modifying these. So if we run this one more time, Alice Hawkins says hello. Bob Hawkins, her son says hello. Alley Dearing says hello and then Bob and Alley get married and now Bob Dearing says hello. But this is a little bit of the wrong sort of thing. We want to have Alley is the one that should have her name being changed because she is the girl here. But I'm sure you guys can understand this practice. You have the option to be able to inherit things and you can reset these variables no matter where you are or no matter what you're doing. Because you can just do that. You can change variables inside the subclass. So that's all I have for you guys today. I know this one is a little bit more complex and we're working with different objects and inheritance and that sort of thing. But I'm sure you guys can wrap your mind around and I'm sorry about that little full name flop every now and again. But I'm sure you guys were probably able to catch it even before I was. If you guys were able you could give me a comment. Maybe like the video, maybe subscribe. I don't know, it's whatever you want to do. But thanks again guys and I'll see you in the next tutorial.