CSE213 Lecture2 F11
CSE213 Lecture2 F11
Procedural programming
Object-oriented programming
An employee is an object
Object
For example
Attributes
Methods
Chapter 1
- 15
The McGraw-Hill
Companies, Inc. Permission
required for reproduction
or display.
Unified Modeling
Language (UML)
Object name: Payroll
Data (attributes): pay
Behaviors (methods)
calculatePay() Includes
return data types after :
Access designation
+ public - private
<Class Name>
Example:
Account
We use a rectangle to
represent a class with
its name appearing
inside the rectangle.
Motorcycle
Chapter 1
- 17
The McGraw-Hill
Companies, Inc. Permission
required for reproduction
or display.
<Object Name>
We use a rectangle to
represent an object and
place the underlined
name of the object
inside the rectangle.
Example:
SV198
Chapter 1
- 18
The McGraw-Hill
Companies, Inc. Permission
required for reproduction
or display.
Example:
SV198 : BankAccount
Chapter 1
- 19
The McGraw-Hill
Companies, Inc. Permission
required for reproduction
or display.
deposit 250.00
SV198 : BankAccount
Ch
ap
ter
120
getCurrentBalance()
SV198 : BankAccount
current balance
Ch
ap
ter
121
MobileRobot
getMaximumSpeed()
maximum speed
Ch
ap
ter
122
SV129 : BankAccount
SV098 : BankAccount
SV211 : BankAccount
current balance
908.55
current balance
1304.98
current balance
354.00
Ch
ap
ter
123
BankAccount
minimum balance
100.00
This line is an
instance-of
relationship.
SV129 : BankAccount
SV098 : BankAccount
SV211 : BankAccount
current balance
908.55
current balance
1304.98
current balance
354.00
Ch
ap
ter
124
SV129 : BankAccount
minimum balance
100.00
current balance
908.55
Ch
ap
ter
125
Encapsulation
Implementation
Superclass
Subclass
A specialization of the superclass with unique
attributes and behaviors
Inherits all attributes and behaviors from the
superclass
Is-a relationships
Has-a relationships
A class has-a collection of other class.
Since composition items do not inherit from
one another, the type of relationship is a
has-a relationship
Example: Car has-a engine, but a car is not
an engine