Document 15071923

advertisement
Matakuliah
Tahun
: T0104 – Metode Perancangan Program
: 2010
OBJECT ORIENTED DESIGN
FOR MULTIPLE CLASSES
Pertemuan - 24
Pertemuan - 24
Object Oriented Design
For Multiple Classes
Objectives
• To become familiar with the steps in creating an
object oriented design for multiple classes a problem
• Develop an object-oriented design solution to
multiple classes a problem
Steps in creating an object-oriented solution
using multiple classes
•
Four steps to follow to create an object-oriented
solution:
1.
Identify the classes and their attributes, responsibilities
and operations
2.
Determine the relationship between the objects and those
classes
3.
Design the algorithm for the operation, using structured
design
4.
Develop a test or driver algorithm to test the solution
Object Oriented Design
For Multiple Classes
• CASE STUDY
Examine Example 13.2 Produce Employee Payslips on
pages 249 through 250.
Object Oriented Design
For Multiple Classes
Problem Satatements: Produce Employee Payslips
•
•
Design a Payroll class to manage the employee payroll for a large
company. The Payroll class is to read a file of employee timesheet and
for each employee, call on the services of a Payslips class to c alculate
that employee’s weekly pay and print a payslips.
The Payslips class is to receive the employee’s number, pay rate and
the number of hours worked in week. The class is to validate the pay
rate field and the hours worked field and, if valid, compute the
employee’s weekly pay and then print it and the input data onto payslip
• Validation: . . .
• Weekly pay calculation: . . .
(Examine Example 13.2 Produce Employee Payslips on pages 249 - 250)
Object Oriented Design
For More Than One Class
OOD SOLUTIONS
Use four steps refered to Example 13.2 Produce Employee Payslips
which depicts all the processes involved in finding the solution as
illustrated on pages 251 through 256 of the textbook
– Step 1: Identify the classes and their attributes, responsibilities
and operations on pages 251 through 252
– Step 2: Determine the relationship between the objects and
those classes on pages 253
– Step 3: Design the algorithms for the operation, using structured
design on pages 253 through 255
– Step 4: Develop a test or driver algorithm to test the solution on
pages 255
Summary
•
Most object-oriented programs need multiple
classes
•
Classes can be related to each other through
association, by aggregation or composition or by
inheritance.
•
When classes are related by inheritance, all
subclasses or child classes inherit the attributes and
methods of the parent class, and supplement them
with attributes and methods needed by the subtype
Summary
•
There are four steps for designing a solution to a
simple multiple-class problem:
1.
Identify the classes and their attributes, responsibilities
and operations.
2.
Determine the relationship between the objects of those
classes.
3.
Design the algorithms for the operations using structured
design.
4.
Develop a test or driver algorithm to test the solution.
The Code
Download