Instance Method

Turn the car

Let’s add method turn to class Carmaker.

Run the code and we get the message The car is turning. We want the car to turn left sometimes and right sometimes.

When we call the turn method we should pass which side to turn.


Method turn should accept the direction of turn.

Let’s change our code.

This concept of passing different values to the same method is called passing argument.

In this case we can say that method turn takes one argument. In the previous lesson we saw that the method gift also takes one argument.