Question:You have been given the responsibility of creating a class named CalcSalary that will
determine the salaries of Certkiller .com's staff. The CalcSalary class includes methods to increment and
decrement staff salaries. You would like to invoke the IncrementSalary and DecrementSalary methods
dynamically at runtime from the sales manager application when needed. You decide to use the Salary
delegate to invoke these methods.
Public Delegate Function Salary(Emp As Employee, Amount As Double) As Boolean
Public Class CalcSalary
' for promotions
End Class -(VB.NET)
 

A Public Sub Review(emp As Employee, amount As Double)
Dim salaryDel As Salary
If emp.Status = QuarterlyReview.OnTarget OrElse emp.Status =
QuarterlyReview.AboveGoals Then
salaryDel.Invoke(CalcSalary.IncrementSalary(emp, amount))
Else
salaryDel.Invoke(CalcSalary.DecrementSalary(emp, amount))
End If
End Sub 

B Public Sub Review(emp As Employee, amount As Double)
Dim salaryDel As Salary
If emp.Status = QuarterlyReview.OnTarget OrElse emp.Status =
QuarterlyReview.AboveGoals Then
salaryDel.Method = CalcSalary.IncrementSalary
Else
salaryDel.Method = CalcSalary.DecrementSalary
End If
salaryDel.Invoke(emp, amount)
End Sub 

C Public Sub Review(emp As Employee, amount As Double)
Dim salaryDel As Salary
If emp.Status = QuarterlyReview.OnTarget OrElse emp.Status =
QuarterlyReview.AboveGoals Then
salaryDel.IncrementSalary(emp, amount)
Else
salaryDel.DecrementSalary(emp, amount)
End If
End Sub 

D Public Sub Review(emp As Employee, amount As Double)
Dim salaryDel As Salary
If emp.Status = QuarterlyReview.OnTarget OrElse emp.Status =
QuarterlyReview.AboveGoals Then
salaryDel = CalcSalary.IncrementSalary
Else
salaryDel = CalcSalary.DecrementSalary
End If
salaryDel.Invoke(emp, amount)
End Sub 

+ Answer
+ Report
Total Preview: 1329

Copyright © 2024. Powered by Intellect Software Ltd