Documente Academic
Documente Profesional
Documente Cultură
Introduction to
Object-Oriented
Programming and
Software
Development
Animated Version
©The McGraw-Hill Companies, Inc. Permission
required for reproduction or display. Chapter 1 - 1
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
<Class Name> We
Weuseuseaarectangle
rectangletoto
represent a class with
represent a class with
its
itsname
nameappearing
appearing
inside
inside therectangle.
the rectangle.
We
Weuse
useaarectangle
rectangleto
to
represent an object and
represent an object and
<Object Name> place
placethe
theunderlined
underlined
name
name of theobject
of the objectinside
inside
the rectangle.
the rectangle.
Example:
This
Thisisisan
anobject
objectnamed
named
SV198 SV198.
SV198.
This
Thisnotation
notationindicates
indicates
<Object Name> : <Class Name> the
the class whichthe
class which the
object is an instance.
object is an instance.
Example:
This
Thistells
tellsan
anobject
object
SV198 : BankAccount SV198
SV198 is an instanceof
is an instance of
the BankAccount class.
the BankAccount class.
Message
Messagedeposit
depositwith
with
the
the argument 250.00isis
argument 250.00
sent
sentto
toaaBankAccount
BankAccount
object SV198.
object SV198.
deposit 250.00
SV198 : BankAccount
Ask
Askfor
forthe
thecurrent
current
balance of this
balance of this
particular
particularaccount.
account.
getCurrentBalance()
SV198 : BankAccount
current balance
The
Thecurrent
currentbalance
balanceof
of
SV198 is returned.
SV198 is returned.
Ask
Askfor
forthe
themaximum
maximum
possible
possible speedfor
speed forall
all
MobileRobot
MobileRobot objectsisis
objects
returned.
returned.
MobileRobot
getMaximumSpeed()
maximum speed
All
Allthree
threeBankAccount
BankAccount The
Theactual
actualdollar
dollar
objects
objects possessthe
possess the amounts
amounts are,of
are, ofcourse,
course,
same instance data
same instance data different.
different.
value
valuecurrent
currentbalance.
balance.
This
Thisline
lineisisan
an
instance-of
instance-of
relationship.
relationship.
SV129 : BankAccount
Checking Savings
Graduate Undergrad
Exercise 1
Exercise 2
Instance variables
•owner
•chasisNo
•plateNo
•manufacturer
•model
•color
•price
Class variables
Exercise 3
Instance variables
•name
•address
•phoneNumber
•numClassesThisSemester
•totalCreditHours
Class variables
•numStudentsRegistered