Matakuliah Tahun : T0104 – Metode Perancangan Program : 2010 OBJECT ORIENTED DESIGN FOR MORE THAN ONE CLASS Pertemuan - 22 Pertemuan - 22 Object Oriented Design For More Than One Class Objectives • To become familiar with the steps in creating an object oriented design for more than one class a problem • Develop an object-oriented design solution to more than one class a problem (simple multiple-class problem) Steps in creating an object-oriented solution using more than one class • 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 More Than One Class • CASE STUDY – Examine Example 12.3 Produce Employee Payslips on pages 232. Object Oriented Design For More Than One Class 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 12.3 Produce Employee Payslips on pages 232) Object Oriented Design For More Than One Class OOD SOLUTIONS Use four steps refered to Example 12.3 Produce Employee Payslips which depicts all the processes involved in finding the solution as illustrated on pages 232 through 238 of the textbook – Step 1: Identify the classes and their attributes, responsibilities and operations on pages 232 through 234 – Step 2: Determine the relationship between the objects and those classes on pages 235 – Step 3: Design the algorithms for the operation, using structured design on pages 235 through 237 – Step 4: Develop a test or driver algorithm to test the solution on pages 237 through 238 Summary • Most object-oriented programs need more than one class • Classes can be related to each other through use, by inheritance, or by composition • 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
© Copyright 2026 Paperzz