Welcome back and this video, I would like to introduce you to classes and objects, and they are a
very important aspect of object oriented programming.
We've seen class before.
For example, our main activity class is one of those classes and a class is, so to say, a blueprint
of an object.
So let's have a look at a specific example.
So let's say I have this very beautiful car here.
And this car.
There's going to be our class that I.
And this car has certain properties.
So props.
And those properties would be, for example, its maximum speed.
Then it could be the amount of tires it has.
So make speed tyres.
Then the amount of windows, maybe even our doors.
So there are cars with two doors.
There are cars with three doors and so forth, so.
Laws would be another property, and then this car has a bunch of skills, for example, it can drive.
So I'm just going to call this one skills.
And there will be.
Drive.
Then what can the car else do?
Well, it can break, hopefully.
Because otherwise we might be screwed.
So it drives, it breaks, it has a bunch of other skills or capabilities in a class.
These properties could be variables.
And those skills could be methods.
So these are things that we have seen already.
Now, the only thing we need to do is we need to create our own class.
So now, as I said, a class is a blueprint.
So when I create a class, I create a blueprint for car objects.
So now I can go ahead and create a car with a max speed of, let's say, two hundred miles per hour.
I can say this car is going to have four tires and it's going to have two doors because it doesn't need
anymore and it's going to have the skill of driving.
And of course, it's also going to have the skill of braking, but it's going to also have a turbo boost
mode.
Then it's going to have the steering capability and so forth.
All right.
And now, of course, this will be my object here.
So this will be another car that I just created, this super fast turbo car that I've just created.
And as I said, it just has this one big door here doesn't need more, right, or one door on one side
and one door on the other side.
Now, the trick question here is, what is the front of this car?
Is it here or is it there?
Well, it doesn't really matter.
I'm just joking.
So that's one object, but then I can go ahead and create a bunch of these objects, so now I can go
ahead and create a bunch of cars and they all look a little different and they all have different colors.
So another property could be the color, for example.
That's a good one.
We'll size could be another one and so forth, so you can see you can have all of these different properties
and now this.
Is the difference between classes and objects, a class is just a blueprint where we define all of these
values, such as properties and skills, and then the objects are the individual cars that are produced,
for example, and this can be used for pretty much anything, right?
You could say a human.
So what are the properties of humans?
Well, we have a certain age that age changes.
Then we have a name.
We have eye colors, hair colors and so forth.
So all of these things would be our properties.
And then we have skills such as breathe or sleep or walk, jump.
All of these things would be our skills and those skills would be our methods that we would create.
All right.
So this is just a quick introduction to classes and we're going to see how we can use classes, how
we can build our own classes, give them those properties and those skills or methods and how we can
create objects of those.
All right.
So I'd say let's dive right into it because it's a lot more fun in practice.
So.
So you're there.