Question: Can someone please provide C# code in Events,Delegates and Reflection for the below problem. ----------------- Agent-Policy XYZ Assurance wants to categorize the policies based on

Can someone please provide C# code in Events,Delegates and Reflection for the below problem.

-----------------

Agent-Policy

XYZ Assurance wants to categorize the policies based on the agent who sold the policy and the Insurance type. Given an Agent name, display the policies that were sold by that agent. Similarly, print the policies in the given Insurance type. Write a program to do the same. They have a list of few policies and want to update the list with a few more policies.

Create a class named Agent with the following attributes

Data Type Variable Name
int _id
string _name

Include appropriate Properties as follows. private string _name; public string Name { get { return _name; } set { _name = value; } } Include a 2 argument constructor with _id and _name as arguments. Create a class named InsuranceType with the following attributes

Data Type Variable Name
int _id
string _type

Include appropriate properties. Include a 2 argument constructor with _id and _type as arguments. Create a class named Policy with the following attributes

Data Type Variable Name
int _id
InsuranceType _insuranceType
Agent _agent
double _premiumPayable

Include appropriate Properties. Include a 4 argument constructor with _id ,_insuranceType,_agent,_premiumPayable as arguments. Create a class named PolicyBO and include the following method,

Method Name Method Description
ListPoliciesByAgent(List policyList, String name) The return type of this method is List. This method returns a list of policies for given agent
ListPoliciesByType(List policyList, String type) The return type of this method is List. This method returns a list of policies under given insurance type

Create a class named Program to test the above classes. The collection for Policy class is prepopulated with predefined values, and get n details from the user and add it to the predefined list. Get the policy details as a single string separated by " , " in the order policy id, insuranceType id, insurance type, agent id, agent name, premium payable. Split the input using Split() method, and store the policy details in a list of type Policy. Create a delegate method named AgentPolicyList(List policyList,string _agentName) with List as return type, and call the ListPoliciesByAgent method using this delegete method,to get the list of policies for given agent. Use String.Format("{0, -20}{1, -20}{2:#.00}", "PolicyId","InsuranceType","PremiumPayable"), to display the policies for agent. Create another delegate method named TypePolicyList(List policyList, string _insuranceType) with List as return type, and call the ListPoliciesByType method using this delegete method,to get the list of policies for given insurance type. String.Format("{0, -20}{1, -20}{2:#.00}", PolicyId,InsuranceType,PremiumPayable), to display the policies for insurance type. Input and Output Format : First line of the input corresponds to the number of policy details, n. Next n lines of the input corresponds to the Policy details separated by " , ". (n+1)th line of the input corresponds to the name of the agent name, to get the policy details. Last input corresponds to the insurance type, to get the policy details. All text in bold corresponds to input and rest corresponds to output. The following logs are already present in the Policy list. These values have to be prefilled before adding new policy details.

PolicyId InsuranceTypeId InsuranceType Agent Id User PremiumPayable
2154 3158 Life Insurance 154 Jacob 25000
3401 3548 Health Insurance 251 Daniel 30000
2549 3154 Vehicle Insurance 154 Jacob 15000
3504 3158 Life Insurance 251 Daniel 20000
2501 3548 Health Insurance 624 Andrew 35000
2509 3154 Vehicle Insurance 624 Andrew 27000

Sample Input and Output : 2 2541,3254,Life Insurance,251,Aiden,20000.50 2571,3846,Health Insurance,154,Joseph,15000 Daniel Policy List PolicyId InsuranceType PremiumPayable 3401 Health Insurance 30000.00 3504 Life Insurance 20000.00 Life Insurance Policy List PolicyId Agent PremiumPayable 2154 Jacob 25000.00 3504 Daniel 20000.00 2541 Aiden 20000.50

--------------------------

Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!