This is the first part of the series (Introduction to object oriented programing) about taking a paragraph of text and identifying objects that are the corner stone of an object oriented program.
Before I go into the actual text let me first establish some basic rules about what is an object. Go get a glass of water. It's the first step to understanding OO programming. Go on, I'll be waiting.
Would you say that the glass of water is an object?
If so, how would you describe it? It's made of a material (glass/plastic), has some weight (heavy/light) and holds some amount of water as in; its capacity. It has properties.
What can you do with it? Smash it, lift it, and last but not least drink from it. It has methods.
Now, take a good look at yours. Is it broken? Is it floating in mid air? Is it half full? Drink some. Is it half empty now? In one word. It has a state.
Oh, and it has a name. Let's call it aGlassOfWater.
Now there are quite a lot of glasses of water out there. Therefore in order to define them we use a class.
A class merely describes what a glass of water really is. Thus, its properties and methods. (indirectly describes its possible states as well but leave that for now)
Oh, and it has a name. Let's call it GlassOfWater.
What about time? Or color? Are these objects? What classes would they describe them? Leave your thoughts below in the comments.
After that, take a look at the survival kit. That will be the basis of our OO analysis.
Disclaimer: "example code"