Objects can perform actions.
Fields work together to describe an object, a car as described by its milk price, year and color,
and based on the requirements, a car can also perform one action.
It can drive.
In this lesson, you're going to have to drive action to the car class.
So what is an action, an action is a method, a function, an action is a method that represents what
the object can do.
From the requirements, we found that a car can perform the drive action, so we need to drive action
to the car class.
So in the car class at a method called drive public, the method is not going to return anything.
It's called drive and it's not going to receive any parameters.
All right, now, every car object that you make from the car class can call the drive method pretty
cool.
And the drive method is going to print every field from the object that calls it as part of a nice string.
So we're going to print line.
You bought the beautiful.
This year.
Add some space.
This color.
Add some more space.
And print the make field of the current object.
And then we'll say for.
The price of the current object.
And after that, we'll say, please drive your car to the nearest exit.
Followed by a new line.
OK, I think it's time to remove these print statements, and I'm going to call the drive action from
the Nissan object.
And sure enough, it prints every field and the car essentially drives.
The object caused the drive method, Jabor runs the drive method.
This points to the current object that's calling the method and the method prints every field that describes
the current object.
I'm going to call this method from every object.
And sure enough, it prints every field from the object that calls it.
In this lesson, you added an action to your car class, an action describes what the object can do,
the requirements tell us that a car can drive.
So you added a drive method to the car class and now every car object can call that action.
And when called, it essentially prints every field that describes the current object as part of a nice
string.