Let's create a car instance
using the Car class.
Now that we have a car instance,
what can we do with it?
In a real car, we can do things
like play music, stop car,
turn lights on.
In our class, we will have to add
these methods to do those things.
Let's add a few methods to our class.
Previously, we have used
reverse
, to_s
and to_i
.
These are methods that
are built into Ruby, so
we do not have to create
those methods by ourselves.
In Ruby, this act of adding
a method in a class is
called defining a method.
So, let's define some methods.
A method starts with def
and
ends with end
.
These methods are empty
and
they don't do anything.
Let's add a message in these methods:
To use these methods, we need
to create a car instance
and
on that car instance,
we need to call the methods.
Run code to see the result.