Solutions
Exercise 1
Refactor the method to use a Result
type with a custom error that encapsulates failure details:
public enum TowerUpgradeError { InsufficientResources, MaxLevelReached, TowerDestroyed } public Result<bool, TowerUpgradeError> UpgradeTower(Tower tower) { // Tower upgrading logic... if (/* insufficient resources */) { return Result.Fail<bool, TowerUpgradeError>(TowerUpgradeError.InsufficientResources); } else if (/* max level reached */) { return Result.Fail<bool, TowerUpgradeError...