Instance Method

Hot coffee Cold Coffee

Let’s add method serve to class Coffeemaker.

When we run the code then we get the message This coffee is being served.

Some people want “hot” coffee and some people want “cold” coffee.


Now we are passing “condition” to serve method so we need to make changes to serve method to accept the type of coffee.

In this case method serve takes one argument. A method can also take more than one argument as we will see in the next lesson.