Exercises
The theory and concepts are only half the learning journey. Now, it’s time to get your hands dirty with some practical exercises. This chapter provides a series of challenging problems to test your understanding of the concepts learned and to reinforce them. Following each problem, you’ll find a proposed solution with detailed explanations.
Exercise 1
Write a program that uses a higher-order function to sort a list of towers in Steve’s game based on their damage output. The sorting function should be passed as a delegate.
Exercise 2
Create a method that takes an Action
and a list of enemies. The Action
should perform a calculation on each enemy’s health and print the result. Test your method using several different Action
s, such as calculating damage taken from different tower types.
Exercise 3
Implement a method that uses a Func
delegate to compare two towers based on their range. The method should return the tower with the longer...