Task 1 – Functor usage
Given a Result<List<Tower>, string>
type that represents a list of towers, where Tower
is a class containing properties such as Id
, Name
, and Damage
, the task is to use the functor concept to apply a function to each tower that appends “(Upgraded)” to the end of its name to indicate that the tower has been upgraded:
public class Tower { public int Id { get; set; } public string Name { get; set; } public int Damage { get; set; } } public Result<List<Tower>, string> UpgradeTowers(List<Tower> towers) { // Write your code here }