Page 40 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 40

Object Oriented Analysis and Design




                    Notes


                                     Case Study  A Payroll Program

                                     Consider a payroll program that processes employee records at a small manufacturing
                                     firm. This company has three types of employees:

                                          Managers: Receive a regular salary.
                                          Office Workers: Receive an hourly wage and are eligible for overtime after 40 hours.

                                          Production Workers: Are paid according to a piece rate.
                                     Structured Approach
                                     FOR EVERY EMPLOYEE DO
                                     BEGIN
                                     IF employee = manager THEN
                                     CALL computeManagerSalary

                                     IF employee = office worker THEN CALL computeOfficeWorkerSalary
                                     IF employee = production worker THEN CALL computeProductionWorkerSalary
                                     END

                                     What if we add two new types of employees?
                                     Temporary office workers ineligible for overtime, junior production workers who receive
                                     an hourly wage plus a lower piece rate.

                                     FOR EVERY EMPLOYEE DO
                                     BEGIN
                                     IF employee = manager THEN
                                     CALL computeManagerSalary
                                     IF employee = office worker THEN

                                     CALL computeOfficeWorker_salary
                                     IF employee = production worker THEN
                                     CALL computeProductionWorker_salary

                                     IF employee = temporary office worker THEN
                                     CALL computeTemporaryOfficeWorkerSalary
                                     IF employee = junior production worker THEN
                                     CALL computeJuniorProductionWorkerSalary
                                     END


                                                                                                         Contd...








          34                                LOVELY PROFESSIONAL UNIVERSITY
   35   36   37   38   39   40   41   42   43   44   45