top of page

Top Social media companies in Mumbai 2019

So let's start by creating our subclause of the game character. Again I'm going to call this play character will find some properties of its own and will leave in what's called override a couple of the methods which is essentially going to be providing a slightly different implementation for some of these functions. Social media companies in Mumbai So I'm going to define it right below Arwa original class the game character and we defined subclauses in a very very similar way.

 

I'm going to give this a name. Play a character now it needs a note there is a subclause by putting in the brackets the name of the superclass in this case game character. OK so now if you'll notice I'm just going to add one proxy so that this goes away. And this is just going to be a number of lives of those lives. Digital media agencies in Mumbai Whoops did not live as we hunt lives and we're going to set the sequel to zero. OK so now because this is inherited everything from game characters so not only the properties up here but also this initializer and these functions. I could actually create an instance of my play a character.

 

So just going to get started actually by deleting all of these because I don't want them to create my new play a character play a character this time this is going to be a play a character instance we can open up the brackets here. And again we can use the same constructs as before we put in the name Max hit points and exposition. So if I put in some name let's go with something like Casey on the first name that came to mind. This one has hit points this time and starts exposition. Social media companies in Mumbai Now again I have access to all of the same properties new this time I need to call the new play a character talk, for example, my current hit points.

 

If I want to print this out that I could do so as just run this like being printed out because I'm now put printing on you play characters hit points but this would be kind of pointless to do this if I didn't go to and to find new stuff within this class. And this is kind of the whole purpose of the subclause super close relationship and inheritance is the ability to get everything in a particular class has and then implement more stuff. OK. Again the whole idea behind this relationship is to eliminate that need to implement exactly the same stuff multiple times because that's actually pretty bad code practice if you're doing the same stuff you're right and exactly the same code over and over again. There's probably a more efficient way to do that. If that's the case. OK.

 

So let's just go about and redefine some of these attributes here. Social media companies in Mumbai So, for example, our new play a character might have lives and also might have let's say an inventory here and I'm just going to set this equal to an empty you know what let's make a dictionary because it makes a little more sense. Actually, you know what in the interest of keeping things simple I'm just going to actually make this an array with a bunch of items in it. So now I play a character has these additional two attributes which I can access. So, for example, you play a character dots lives. OK. I can access that.

 

But what I can do is say you game character dot lives because that doesn't exist on our new game character that's only to play a character. So whereas the subclause gains everything that superclass has not necessarily the other way around. So my goal here is to set these two values up. So in order to do so, I'm going to need to provide a new definition for my initializer. So I want to initialize my inventory with maybe a couple of different items such as like a shirt and pants or something. And then we also want to set this Carrot's up with a few Lyce or Z having zero lives is bad.

 

So the way we would do this is by defining yet another initializer. So deaths. And that's OK we start with self again. We want to take in the same three values as before but we want to take in some additional values or at the very least set these values up. Social media companies in Mumbai So actually we weren't taking some additional inventory values or an additional number of lives we going to each of these play characters out with the same default three lives and default in inventory with two items in it. So we took a name we'll take in a max hit points we'll take in a current x position and now we're going to need to first call upon the superclasses initializer and then set up additional stuff. Now the reason we're calling on the super close is initializer is again to avoid writing the same code twice now.

 

Cool on this and it's actually given me this error saying it needs to call our superclass. Social media companies in Mumbai The way I get around this is by calling my super OK and how oh wow I actually filled in all fours automatically. So we need the super keyword in the brackets we need that class that we're working in play a character we need to sell keyword and then we call DOT it and then we Palsson the same values like we were like we would if we're calling on the initializer here. So, in this case, the values will be passed again will be our name max hit points on our exposition. So now essentially what this will accomplish is when we call on our initializer we're still pulse can name hit points and x position and now it's essentially going to invoke the superclasses called this and it will perform the same initializing as before.

 

But now we can define additional stuff such as. Self-taught lives. Siri can actually spell that equals three. And then they can say something like Salto Social media companies in Mumbai inventory equals just some array with some items and going to say something like shirts and pants. 

bottom of page