0% found this document useful (0 votes)
131 views

Event Example

1) Create an interface named ITax that defines an abstract ComputeTax() method to return a float. 2) Create a Payment class that inherits from ITax and overrides ComputeTax() to return tax as 10% of the Amount attribute. 3) Add an event to the Payment class to notify when the Amount is edited.

Uploaded by

Long Híp
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views

Event Example

1) Create an interface named ITax that defines an abstract ComputeTax() method to return a float. 2) Create a Payment class that inherits from ITax and overrides ComputeTax() to return tax as 10% of the Amount attribute. 3) Add an event to the Payment class to notify when the Amount is edited.

Uploaded by

Long Híp
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

(3 points)

You are asked to write a console application which allow user manage his/her Payment. Your tasks
include several of following steps:

1. You should create an interface named ITax , which define [ float ComputeTax() ] method, this is
an abstract method (no-code method). (1 point)

2. Your Payment class will inherited ITax. Payment contains only one attribute named [ float Amount
]. Your task is to override the ComputeTax () method such that : tax = 10% of Amount; (1 point)

3. Create an event to notify user when the Amount be edited; (1 point)

Hint:

The main function of your application should look like following (it is not necessary to have exactly the
same code, but this is good enough to test your application):

static void Main(string[] args)

Payment payment = new Payment() { amount = 1000 };

payment.AmountChanged += notifyAmountChanged; // your handling function

payment.Amount = 990;

Console.WriteLine( “Tax:” + payment. ComputeTax ());

You application should display like following:

Amount changed – old value: 1000, new value : 990

Tax: 99.0

You might also like