6. What comprises an object?
● Things that describe it (properties or attributes)
● Things that the object can do or can be done to it (actions, methods or
functions)
7. What defines an object?
A class is what describes that MyObject comprises of and how MySpecific
object will be born to life, instantiated (constructor).
8. Lets take a human as an object
● Constructor - give birth to a single human (mostly), the constructor is a
function that will return the object Human upon its completion
● Properties (describe the object)
o Height (float)
o Weight (float)
o EyeColor (String)
o Sex (boolean)
o IsCryingNow (boolean)
● Methods
o Walk
o Talk
o GoToSleep
o Cry(true/false)
9. This is how typically a code using a Human will look:
Human myHumanChild = new Human(typeChild);
Human myHumanAdult = new Human(typeAdult);
myHumanChild.Walk();
myHumanChild.EyeColor = “blue”;
If (myHumanChild.IsCryingNow = true){
….
}
else{
myHumanChild.Cry(true);
How typically code looks
10. How to code all of this?
Properties, Methods and constructors are actually just functions.
The distinction is in our minds, to make it easier to understand (in most
languages).
11. Collections
A collection is a number of objects.
For instance:
Humanity (plural) contains many Humans (single).
Collections can have a designated data type in some languages, or be just
arrays of objects or array lists.