Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

This assignment is about delegates, events, and lambda expressions. This assignment will start with the attached file "CSD228_Assignment4_solution (1)" You are to make the following changes: Add a new

This assignment is about delegates, events, and lambda expressions.

This assignment will start with the attached file "CSD228_Assignment4_solution (1)"

You are to make the following changes:

  1. Add a new class called ManagerEventArgs (similar to CarEventArgs in the attached file "Chap10").Instead of a string, the ManagerEventArgs classdefinestwo data members to hold references totheManager andEmployee passedto the AddReport method call. Change the constructor to take these two arguments and initialize the data members. Add a member virtual Message method to the ManagerEventArgs class thatreturns the following message string:
    • has reports, can not add report
  2. Remove the TooManyReportsException you created in assignment 4, and replace it with a generic event using the EventHandler generic class with the ManagerEventArgs class you created in step 1. Change the AddReport method to raise this event where you previously used the TooManyReportsException, passing the manager and report from the AddReports method call to the ManagerEventArgs constructor. You should design your event so that one only need to register an event handler once to catch events on any managers (i.e., it is not necessary to register an event on every individual manager).
  3. Change the static Main method to register three handlers for the TooManyReports immediately after the employee list is defined - one handler using the traditional delegate syntax (i.e., a static method in the Program class), one using the anonymous method delegate syntax, and one using a lambda expression. All three events should call the Message virtual method that you created in step 1 and print out the message to the console. Remove the catch block entirely, but keep the statements from the try block - just remove the 'try' keyword and the extra set of braces {} from the try block.

If done correctly, the same error message should be printed three times.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question