Professional Documents
Culture Documents
Lecture 02 17032022 020623pm
Lecture 02 17032022 020623pm
Lecture 02 17032022 020623pm
Understanding
the difference Object Oriented Programming
Object oriented programming allows the programmer to
represent real-world scenarios using objects.
An object is any entity that has states and behaviors.
States represent the attributes or data of an object, whereas the
methods represent the behaviors of objects.
Student, Employee, Book etc. are objects.
These objects interact with other objects by passing messages.
Class
A blueprint for creating an object
It is necessary to have a class to create objects
Object Oriented
Terms
Object
An instance of a Class
Chinese
Language English
Urdu
Spanish Student
Person
Teacher
Employee
Dog
Animal
Cat
Snake
Student
University
Cow
Teacher
Departments
Courses
OO Software
A technique for system modeling
What is Object- OO model consists of several objects
Orientation
A model is an abstraction of something
Purpose is to understand the Product before
Model developing it.
OO Model
Examples
Object
Example
Example
Write a class named Car that has the following member variables:
• yearModel: An int that holds the car’s year model.
• name: A string that holds the name of the car.
• company: A string that holds the company of the car.
• speed: An int that holds the car’s current speed.
Mutator:
Appropriate accessor functions to set the values of object’s yearModel, name, company,
and speed member variables.
Accessor:
Activity Appropriate accessor functions to get the values stored in an object’s yearModel, make,
and speed member variables.
Accelerate:
The accelerate function should add 5 to the speed member variable each time it is
called.
Brake:
The brake function should subtract 5 from the speed member variable each time it is
called.