Lecture 2.part1
Lecture 2.part1
Objectives
After you have read and studied this chapter, you
should be able to
• Name the basic components of object-oriented
programming
• Differentiate classes and objects.
• Differentiate class and instance methods.
• Differentiate class and instance data values.
• Draw program diagrams using icons for classes and
objects
• Describe significance of inheritance in object-oriented
programs
• Name and explain the stages of the software lifecycle
Classes and Objects
We use a rectangle to
represent an object and
<Object Name> place the underlined
name of the object
inside the rectangle.
Example:
Example:
deposit 250.00
SV198 : BankAccount
Sending a Message and Getting an Answer
getCurrentBalance()
SV198 : BankAccount
current balance
MobileRobot
getMaximumSpeed()
maximum speed
Class and Instance Data Values
• An object is comprised of data values and methods.
• An instance data value is used to maintain information specific to individual
instances. For example, each BankAccount object maintains its balance.
• A class data value is used to maintain information shared by all instances or
aggregate information about the instances.
• For example, minimum balance is the information shared by all Account objects,
whereas the average balance of all BankAccount objects is an aggregate
information.
Sample Instance Data Value
This line is an
instance-of
relationship.
SV129 : BankAccount
Checking Savings
Inheritance Hierarchy
• An example of inheritance hierarchy among different
types of students.
Student
Graduate Undergrad