Chapter 1. Object Oriented Concepts
Chapter 1. Object Oriented Concepts
Class
• Class is a container that holds
– Data members
– Function(or methods)
members
• It is like a blueprint for an object
Object
• Is an instance of class
17
Encapsulation
18
Inheritance
Vehicle Object
MDI
Maruti- Button Textbox Dialog
CBZ Discover Santro parent
SX4
20
Message Passing
• Message passing in OOP is a mechanism for
objects to communicate and interact with
each other by sending messages.
• It involves invoking methods on objects, which
can lead to the exchange of information,
execution of a specific behaviour, or
modification of an object's state.
Object Oriented Design
• Object oriented design is the art of assigning
the right responsibilities to the right objects
and creating a clear structure with loose
coupling and high cohesion.
time++;
}
return 0;
}
• In the main function, we create a Road object of length
1000 meters and a Car object. We then run a
simulation loop where the car accelerates by 2 m/s^2
and moves for 1 second at each iteration until the car
reaches the end of the road (its position becomes
equal to or greater than the road length).
• Through this simulation, we can observe how the car
behaves, accelerates, and moves on the road based on
the defined rules of the simulation. The simulation
provides a way to study the car's behavior in a virtual
environment, which can be useful for testing or
predicting real-world scenarios without the need for
physical experimentation.
Coping with Complexity