Professional Documents
Culture Documents
PROGRAMMING
W
E
E
K
Revision Of
Object-Oriented
Programming
OBJECTIVES
After studying this chapter you should be able to:
Understand and apply the principles of good
programming in developing Java program.
Elaborate the characteristics of Object-Oriented
Programming.
Develop Java program by using proper problem
solving technique.
Graphical Representation of a
Class
<Class Name>
Example:
Account
We
Weuse
useaarectangle
rectangleto
to
represent
a
class
with
represent a class with
its
itsname
nameappearing
appearing
inside
the
inside therectangle.
rectangle.
Motorcycle
We
Weuse
useaarectangle
rectangleto
to
represent
an
object
represent an objectand
and
place
the
underlined
place the underlined
name
nameof
ofthe
theobject
object
inside
the
rectangle.
inside the rectangle.
Example:
SV198
This
Thisisisan
anobject
objectnamed
named
SV198.
SV198.
Sending a Message
Message
Messagedeposit
depositwith
with
the
argument
250.00
the argument 250.00isis
sent
sentto
toaaBankAccount
BankAccount
object
SV198.
object SV198.
deposit 250.00
SV198 : BankAccount
SV098 : BankAccount
SV211 : BankAccount
current balance
908.55
current balance
1304.98
current balance
All
Allthree
threeBankAccount
BankAccount
objects
possess
objects possessthe
the
same
instance
data
same instance data
value
valuecurrent
currentbalance.
balance.
354.00
The
Theactual
actualdollar
dollar
amounts
are,
amounts are,of
ofcourse,
course,
different.
different.
There
Thereisisone
onecopy
copyofof
minimum
minimumbalance
balancefor
for
the
whole
class
and
the whole class and
shared
sharedby
byall
allinstances.
instances.
This
Thisline
lineisisan
an
instance-of
instance-of
relationship.
relationship.
SV129 : BankAccount
SV098 : BankAccount
SV211 : BankAccount
current balance
908.55
current balance
1304.98
current balance
354.00
Class Comment
Method Comment
Sample
Symbol
Person
Company
Voter
Character
public
+
protected
#
private
Circle
Sphere
Cylinder
Subclass
Area()
Sphere
Cylinder
Area()
Luas()
Luas()
OVERLOADING
Name
Person
composition
Address
aggregation
Problem-solving Process
In the programming environment, the problemsolving process involves the following steps:
Analyze the problem, outline the problem and its
solution requirements and design an algorithm to solve
the problem.
Implement the algorithm in a programming language,
such as Java and verify that the algorithm works.
Maintain the program by using and modifying it if the
problem domain changes.
Problem-solving Process
References
Thomas Wu. C, An Introduction To Object-Oriented
Programming With Java. (2006). Mc Graw Hill.
Liang, D. (2005). Introduction To Java programming.
Prentice Hall.
Horstman, C. (2006). Big Java (2nd ed). New York: John
Wiley & Sons.