Modeling real-world objects
To get a better understanding of how we can model objects in OOP, let's try to go through a couple of examples from the real world. As you will see, there are a lot of similarities when we try to model real-world objects and objects in our programs.
Modeling a mug
Using our knowledge about what OOP is, let's look at a more concrete example. Let's take a look at the object in the following photograph:
Using our real-world knowledge combined with common sense, what could be some characteristics of this mug? Instead of considering the actual values or the specifics of the mug, let's try to come up with a set of properties this mug has. We could say that the mug has a color which is the color of the ceramic, which in this case is white. We could also say something about the print on the mug. Perhaps we could generalize this into being an image or print that a mug can have. Maybe we could also model the material of the mug, which in general could be glass, ceramic,...