So how did you find that fairly easy?
I'm guessing the hard part was figuring out what variables you were going to use.
Well, here's my version.
A class of gadget has keyboard, has SIM card.
So gadget's usually don't have a SIM card and gadgets usually do have a keyboard.
How would we subclass that to define a smartphone?
Well.
We would say smartphone inherits from gadget and we're going to override its initial.
So even though we haven't specified the initialise here, here, we're still going to override it.
We're going to call super.
So it's still initializes everything because look what happens if we leave this out.
Give it a second to catch up, we get Megaera.
And then after it's done what it does, we then set keyboard to false because smartphones don't really
these days or physical keyboard and self-taught has SIM card equal to true.
And then, of course, if we're going to print that out, we could say smartphone object dot.
Has keyboard.
And that will say false.
OK, now it's important to note that and I I should have mentioned this before smartphone.
Smartphone.
Are all different objects, so if I change keyboard on this one, it has absolutely no effect on this
one or this one.
Every object has its own copy of the variables and the functionality inside of it, so they each have
their own state, right state represents what the data looks like at any one point in time inside the
object.
So I should have really mentioned that, and it doesn't matter how many times you create it, the state
is always the same.
The state is always inside, contained inside of that object.
Now, some languages allow you to use what are called static variables.
I would say avoid static variables like the plague.
So if we're in a smartphone, if you're in C sharp, you'd have a static var.
What else is on a smartphone?
I don't know.
Battery equals true.
OK, now it's just going to work on this.
Apparently, it was just a random guess that in that case for this this is going to be the same for
all of these bright.
Even if you try to change it, but if I try and take a battery, I can't access it.
Why is that?
Because it has nothing to do with the object or instance we created, it has to do with the original
class so I can access it if I don't put the brackets here to make it into an object.
And I'm just looking at the class.
OK, so that's how that works.
Avoid static's really, really, really, really avoid static's if you can.
Again, some situations where you have to use them or put my hand up and admit this, you're being lazy,
you just throw in a static here and there, but for the most part and please, please avoid them.
All right.
That's inheritance done.