Coffee maker class definition
A coffee maker machine makes coffee. A coffee maker machine itself is not a coffee. However a coffee maker machine can produce a coffee.
Let’s create a class named
class Coffeemaker end
Now we need to ask this
Coffeemaker class to produce a coffee.
In the last lesson we saw that we can make a car out of a class using
new. So let’s use
new here also to make a coffee out of
So far we have built coffee and car out ouf their classes.
The things that a class makes are called instance.
In this case
coffee1 is an instance of class
In the last lesson
car1 was an instance of class
Let’s go over it again.
A class is something that builds or makes something.
So far we have seen two classes -
The things that are built by these classes are called instances.
A car is an instance of the class
A coffee is an instance of the class
I know all this class and instance things are still confusing. That’s why we will discuss it again in the next lesson.